OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 "vm/dart_entry.h" | 5 #include "vm/dart_entry.h" |
6 | 6 |
7 #include "vm/class_finalizer.h" | 7 #include "vm/class_finalizer.h" |
8 #include "vm/code_generator.h" | 8 #include "vm/code_generator.h" |
9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
10 #include "vm/debugger.h" | 10 #include "vm/debugger.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 // Bottomed out. | 47 // Bottomed out. |
48 isolate_->ClearStackLimit(); | 48 isolate_->ClearStackLimit(); |
49 } | 49 } |
50 } | 50 } |
51 | 51 |
52 private: | 52 private: |
53 Isolate* isolate_; | 53 Isolate* isolate_; |
54 }; | 54 }; |
55 | 55 |
56 | 56 |
| 57 // Clears/restores Isolate::long_jump_base on construction/destruction. |
| 58 // Ensures that we do not attempt to long jump across Dart frames. |
| 59 class SuspendLongJumpScope : public StackResource { |
| 60 public: |
| 61 explicit SuspendLongJumpScope(Isolate* isolate) |
| 62 : StackResource(isolate), |
| 63 saved_long_jump_base_(isolate->long_jump_base()) { |
| 64 isolate->set_long_jump_base(NULL); |
| 65 } |
| 66 |
| 67 ~SuspendLongJumpScope() { |
| 68 ASSERT(isolate()->long_jump_base() == NULL); |
| 69 isolate()->set_long_jump_base(saved_long_jump_base_); |
| 70 } |
| 71 |
| 72 private: |
| 73 LongJumpScope* saved_long_jump_base_; |
| 74 }; |
| 75 |
| 76 |
57 RawObject* DartEntry::InvokeFunction(const Function& function, | 77 RawObject* DartEntry::InvokeFunction(const Function& function, |
58 const Array& arguments, | 78 const Array& arguments, |
59 const Array& arguments_descriptor) { | 79 const Array& arguments_descriptor) { |
60 // Get the entrypoint corresponding to the function specified, this | 80 // Get the entrypoint corresponding to the function specified, this |
61 // will result in a compilation of the function if it is not already | 81 // will result in a compilation of the function if it is not already |
62 // compiled. | 82 // compiled. |
63 Isolate* isolate = Isolate::Current(); | 83 Isolate* isolate = Isolate::Current(); |
64 if (!function.HasCode()) { | 84 if (!function.HasCode()) { |
65 const Error& error = Error::Handle( | 85 const Error& error = Error::Handle( |
66 isolate, Compiler::CompileFunction(isolate, function)); | 86 isolate, Compiler::CompileFunction(isolate, function)); |
67 if (!error.IsNull()) { | 87 if (!error.IsNull()) { |
68 return error.raw(); | 88 return error.raw(); |
69 } | 89 } |
70 } | 90 } |
71 // Now Call the invoke stub which will invoke the dart function. | 91 // Now Call the invoke stub which will invoke the dart function. |
72 invokestub entrypoint = reinterpret_cast<invokestub>( | 92 invokestub entrypoint = reinterpret_cast<invokestub>( |
73 isolate->stub_code()->InvokeDartCodeEntryPoint()); | 93 isolate->stub_code()->InvokeDartCodeEntryPoint()); |
74 const Code& code = Code::Handle(isolate, function.CurrentCode()); | 94 const Code& code = Code::Handle(isolate, function.CurrentCode()); |
75 ASSERT(!code.IsNull()); | 95 ASSERT(!code.IsNull()); |
76 ASSERT(Isolate::Current()->no_callback_scope_depth() == 0); | 96 ASSERT(Isolate::Current()->no_callback_scope_depth() == 0); |
77 ScopedIsolateStackLimits stack_limit(isolate); | 97 ScopedIsolateStackLimits stack_limit(isolate); |
| 98 SuspendLongJumpScope suspend_long_jump_scope(isolate); |
78 #if defined(USING_SIMULATOR) | 99 #if defined(USING_SIMULATOR) |
79 #if defined(ARCH_IS_64_BIT) | 100 #if defined(ARCH_IS_64_BIT) |
80 // TODO(zra): Change to intptr_t so we have only one case. | 101 // TODO(zra): Change to intptr_t so we have only one case. |
81 return bit_copy<RawObject*, int64_t>(Simulator::Current()->Call( | 102 return bit_copy<RawObject*, int64_t>(Simulator::Current()->Call( |
82 reinterpret_cast<int64_t>(entrypoint), | 103 reinterpret_cast<int64_t>(entrypoint), |
83 static_cast<int64_t>(code.EntryPoint()), | 104 static_cast<int64_t>(code.EntryPoint()), |
84 reinterpret_cast<int64_t>(&arguments_descriptor), | 105 reinterpret_cast<int64_t>(&arguments_descriptor), |
85 reinterpret_cast<int64_t>(&arguments), | 106 reinterpret_cast<int64_t>(&arguments), |
86 0)); | 107 0)); |
87 #else | 108 #else |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 const Array& args = Array::Handle(Array::New(kNumArguments)); | 516 const Array& args = Array::Handle(Array::New(kNumArguments)); |
496 args.SetAt(0, map); | 517 args.SetAt(0, map); |
497 args.SetAt(1, key); | 518 args.SetAt(1, key); |
498 args.SetAt(2, value); | 519 args.SetAt(2, value); |
499 const Object& result = Object::Handle(DartEntry::InvokeFunction(function, | 520 const Object& result = Object::Handle(DartEntry::InvokeFunction(function, |
500 args)); | 521 args)); |
501 return result.raw(); | 522 return result.raw(); |
502 } | 523 } |
503 | 524 |
504 } // namespace dart | 525 } // namespace dart |
OLD | NEW |