@@ -18,6 +18,7 @@ namespace dart {
1818DECLARE_FLAG (bool , check_code_pointer);
1919DECLARE_FLAG (bool , inline_alloc);
2020DECLARE_FLAG (bool , precompiled_mode);
21+ DECLARE_FLAG (bool , use_slow_path);
2122
2223DEFINE_FLAG (bool , use_far_branches, false , " Always use far branches" );
2324
@@ -1312,12 +1313,13 @@ void Assembler::LeaveDartFrame(RestorePP restore_pp) {
13121313}
13131314
13141315void Assembler::TransitionGeneratedToNative (Register destination,
1315- Register new_exit_rame ,
1316+ Register new_exit_frame ,
13161317 Register state) {
13171318 Register addr = TMP2;
1319+ ASSERT (addr != state);
13181320
13191321 // Save exit frame information to enable stack walking.
1320- StoreToOffset (new_exit_rame , THR,
1322+ StoreToOffset (new_exit_frame , THR,
13211323 compiler::target::Thread::top_exit_frame_info_offset ());
13221324
13231325 // Mark that the thread is executing native code.
@@ -1326,17 +1328,20 @@ void Assembler::TransitionGeneratedToNative(Register destination,
13261328 StoreToOffset (state, THR, compiler::target::Thread::execution_state_offset ());
13271329
13281330 Label slow_path, done, retry;
1329- movz (addr, Immediate (compiler::target::Thread::safepoint_state_offset ()), 0 );
1330- add (addr, THR, Operand (addr));
1331- Bind (&retry);
1332- ldxr (state, addr);
1333- cmp (state, Operand (Thread::safepoint_state_unacquired ()));
1334- b (&slow_path, NE);
1335-
1336- movz (state, Immediate (Thread::safepoint_state_acquired ()), 0 );
1337- stxr (TMP, state, addr);
1338- cbz (&done, TMP); // 0 means stxr was successful.
1339- b (&retry);
1331+ if (!FLAG_use_slow_path) {
1332+ movz (addr, Immediate (compiler::target::Thread::safepoint_state_offset ()),
1333+ 0 );
1334+ add (addr, THR, Operand (addr));
1335+ Bind (&retry);
1336+ ldxr (state, addr);
1337+ cmp (state, Operand (Thread::safepoint_state_unacquired ()));
1338+ b (&slow_path, NE);
1339+
1340+ movz (state, Immediate (Thread::safepoint_state_acquired ()), 0 );
1341+ stxr (TMP, state, addr);
1342+ cbz (&done, TMP); // 0 means stxr was successful.
1343+ b (&retry);
1344+ }
13401345
13411346 Bind (&slow_path);
13421347 ldr (addr,
@@ -1349,24 +1354,28 @@ void Assembler::TransitionGeneratedToNative(Register destination,
13491354
13501355void Assembler::TransitionNativeToGenerated (Register state) {
13511356 Register addr = TMP2;
1357+ ASSERT (addr != state);
13521358
13531359 Label slow_path, done, retry;
1354- movz (addr, Immediate (compiler::target::Thread::safepoint_state_offset ()), 0 );
1355- add (addr, THR, Operand (addr));
1356- Bind (&retry);
1357- ldxr (state, addr);
1358- cmp (state, Operand (Thread::safepoint_state_acquired ()));
1359- b (&slow_path, NE);
1360-
1361- movz (state, Immediate (Thread::safepoint_state_unacquired ()), 0 );
1362- stxr (TMP, state, addr);
1363- cbz (&done, TMP); // 0 means stxr was successful.
1364- b (&retry);
1360+ if (!FLAG_use_slow_path) {
1361+ movz (addr, Immediate (compiler::target::Thread::safepoint_state_offset ()),
1362+ 0 );
1363+ add (addr, THR, Operand (addr));
1364+ Bind (&retry);
1365+ ldxr (state, addr);
1366+ cmp (state, Operand (Thread::safepoint_state_acquired ()));
1367+ b (&slow_path, NE);
1368+
1369+ movz (state, Immediate (Thread::safepoint_state_unacquired ()), 0 );
1370+ stxr (TMP, state, addr);
1371+ cbz (&done, TMP); // 0 means stxr was successful.
1372+ b (&retry);
1373+ }
13651374
13661375 Bind (&slow_path);
13671376 ldr (addr,
13681377 Address (THR, compiler::target::Thread::exit_safepoint_stub_offset ()));
1369- ldr (addr, FieldAddress (TMP , compiler::target::Code::entry_point_offset ()));
1378+ ldr (addr, FieldAddress (addr , compiler::target::Code::entry_point_offset ()));
13701379 blr (addr);
13711380
13721381 Bind (&done);
0 commit comments