Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(773)

Side by Side Diff: runtime/vm/simulator_dbc.cc

Issue 2473213002: DBC: When calling DRT_OptimizeInvokedFunction, patch the stack to have a stub instead of the to-be-… (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include <setjmp.h> // NOLINT 5 #include <setjmp.h> // NOLINT
6 #include <stdlib.h> 6 #include <stdlib.h>
7 7
8 #include "vm/globals.h" 8 #include "vm/globals.h"
9 #if defined(TARGET_ARCH_DBC) 9 #if defined(TARGET_ARCH_DBC)
10 10
(...skipping 20 matching lines...) Expand all
31 #include "vm/symbols.h" 31 #include "vm/symbols.h"
32 32
33 namespace dart { 33 namespace dart {
34 34
35 DEFINE_FLAG(uint64_t, trace_sim_after, ULLONG_MAX, 35 DEFINE_FLAG(uint64_t, trace_sim_after, ULLONG_MAX,
36 "Trace simulator execution after instruction count reached."); 36 "Trace simulator execution after instruction count reached.");
37 DEFINE_FLAG(uint64_t, stop_sim_at, ULLONG_MAX, 37 DEFINE_FLAG(uint64_t, stop_sim_at, ULLONG_MAX,
38 "Instruction address or instruction count to stop simulator at."); 38 "Instruction address or instruction count to stop simulator at.");
39 39
40 #define LIKELY(cond) __builtin_expect((cond), 1) 40 #define LIKELY(cond) __builtin_expect((cond), 1)
41 #define UNLIKELY(cond) __builtin_expect((cond), 0)
41 42
42 // SimulatorSetjmpBuffer are linked together, and the last created one 43 // SimulatorSetjmpBuffer are linked together, and the last created one
43 // is referenced by the Simulator. When an exception is thrown, the exception 44 // is referenced by the Simulator. When an exception is thrown, the exception
44 // runtime looks at where to jump and finds the corresponding 45 // runtime looks at where to jump and finds the corresponding
45 // SimulatorSetjmpBuffer based on the stack pointer of the exception handler. 46 // SimulatorSetjmpBuffer based on the stack pointer of the exception handler.
46 // The runtime then does a Longjmp on that buffer to return to the simulator. 47 // The runtime then does a Longjmp on that buffer to return to the simulator.
47 class SimulatorSetjmpBuffer { 48 class SimulatorSetjmpBuffer {
48 public: 49 public:
49 void Longjmp() { 50 void Longjmp() {
50 // "This" is now the last setjmp buffer. 51 // "This" is now the last setjmp buffer.
(...skipping 1377 matching lines...) Expand 10 before | Expand all | Expand 10 after
1428 const uint8_t increment = rA; 1429 const uint8_t increment = rA;
1429 const uint16_t threshold = rD; 1430 const uint16_t threshold = rD;
1430 RawFunction* f = FrameFunction(FP); 1431 RawFunction* f = FrameFunction(FP);
1431 int32_t counter = f->ptr()->usage_counter_; 1432 int32_t counter = f->ptr()->usage_counter_;
1432 // Note: we don't increment usage counter in the prologue of optimized 1433 // Note: we don't increment usage counter in the prologue of optimized
1433 // functions. 1434 // functions.
1434 if (increment) { 1435 if (increment) {
1435 counter += increment; 1436 counter += increment;
1436 f->ptr()->usage_counter_ = counter; 1437 f->ptr()->usage_counter_ = counter;
1437 } 1438 }
1438 if (counter >= threshold) { 1439 if (UNLIKELY(counter >= threshold)) {
1439 FP[0] = f; 1440 FP[0] = f;
1440 FP[1] = 0; 1441 FP[1] = 0;
1442
1443 // Make the DRT_OptimizeInvokedFunction see a stub as its caller for
1444 // consistency with the other architectures, and to avoid needing to
1445 // generate a stackmap for the HotCheck pc.
1446 const StubEntry* stub = StubCode::OptimizeFunction_entry();
zra 2016/11/04 16:01:05 Is it okay for this to be *any* stub, or does it h
rmacnak 2016/11/04 16:50:27 Right, any stub because we'll switch to the new op
1447 FP[kPcMarkerSlotFromFp] = stub->code();
1448 pc = reinterpret_cast<uint32_t*>(stub->EntryPoint());
1449
1441 Exit(thread, FP, FP + 2, pc); 1450 Exit(thread, FP, FP + 2, pc);
1442 NativeArguments args(thread, 1, FP, FP + 1); 1451 NativeArguments args(thread, 1, FP, FP + 1);
1443 INVOKE_RUNTIME(DRT_OptimizeInvokedFunction, args); 1452 INVOKE_RUNTIME(DRT_OptimizeInvokedFunction, args);
1444 { 1453 {
1445 // DRT_OptimizeInvokedFunction returns the code object to execute. 1454 // DRT_OptimizeInvokedFunction returns the code object to execute.
1446 ASSERT(FP[1]->GetClassId() == kFunctionCid); 1455 ASSERT(FP[1]->GetClassId() == kFunctionCid);
1447 RawFunction* function = static_cast<RawFunction*>(FP[1]); 1456 RawFunction* function = static_cast<RawFunction*>(FP[1]);
1448 RawCode* code = function->ptr()->code_; 1457 RawCode* code = function->ptr()->code_;
1449 SimulatorHelpers::SetFrameCode(FP, code); 1458 SimulatorHelpers::SetFrameCode(FP, code);
1450 pp = code->ptr()->object_pool_->ptr(); 1459 pp = code->ptr()->object_pool_->ptr();
(...skipping 2303 matching lines...) Expand 10 before | Expand all | Expand 10 after
3754 pc_ = pc; 3763 pc_ = pc;
3755 special_[kExceptionSpecialIndex] = raw_exception; 3764 special_[kExceptionSpecialIndex] = raw_exception;
3756 special_[kStacktraceSpecialIndex] = raw_stacktrace; 3765 special_[kStacktraceSpecialIndex] = raw_stacktrace;
3757 buf->Longjmp(); 3766 buf->Longjmp();
3758 UNREACHABLE(); 3767 UNREACHABLE();
3759 } 3768 }
3760 3769
3761 } // namespace dart 3770 } // namespace dart
3762 3771
3763 #endif // defined TARGET_ARCH_DBC 3772 #endif // defined TARGET_ARCH_DBC
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698