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

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

Issue 1812753002: - Move (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 months 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) 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 23 matching lines...) Expand all
34 public: 34 public:
35 explicit ScopedIsolateStackLimits(Thread* thread) 35 explicit ScopedIsolateStackLimits(Thread* thread)
36 : thread_(thread), saved_stack_limit_(0) { 36 : thread_(thread), saved_stack_limit_(0) {
37 ASSERT(thread != NULL); 37 ASSERT(thread != NULL);
38 // Set the thread's stack_base based on the current 38 // Set the thread's stack_base based on the current
39 // stack pointer, we keep refining this value as we 39 // stack pointer, we keep refining this value as we
40 // see higher stack pointers (Note: we assume the stack 40 // see higher stack pointers (Note: we assume the stack
41 // grows from high to low addresses). 41 // grows from high to low addresses).
42 OSThread* os_thread = thread->os_thread(); 42 OSThread* os_thread = thread->os_thread();
43 ASSERT(os_thread != NULL); 43 ASSERT(os_thread != NULL);
44 uword current_sp = Isolate::GetCurrentStackPointer(); 44 uword current_sp = Thread::GetCurrentStackPointer();
45 if (current_sp > os_thread->stack_base()) { 45 if (current_sp > os_thread->stack_base()) {
46 os_thread->set_stack_base(current_sp); 46 os_thread->set_stack_base(current_sp);
47 } 47 }
48 // Save the Isolate's current stack limit and adjust the stack 48 // Save the Thread's current stack limit and adjust the stack
49 // limit based on the thread's stack_base. 49 // limit based on the thread's stack_base.
50 Isolate* isolate = thread->isolate(); 50 ASSERT(thread->isolate() == Isolate::Current());
51 ASSERT(isolate == Isolate::Current()); 51 saved_stack_limit_ = thread->saved_stack_limit();
52 saved_stack_limit_ = isolate->saved_stack_limit(); 52 thread->SetStackLimitFromStackBase(os_thread->stack_base());
53 isolate->SetStackLimitFromStackBase(os_thread->stack_base());
54 } 53 }
55 54
56 ~ScopedIsolateStackLimits() { 55 ~ScopedIsolateStackLimits() {
57 Isolate* isolate = thread_->isolate(); 56 ASSERT(thread_->isolate() == Isolate::Current());
58 ASSERT(isolate == Isolate::Current());
59 // Since we started with a stack limit of 0 we should be getting back 57 // Since we started with a stack limit of 0 we should be getting back
60 // to a stack limit of 0 when all nested invocations are done and 58 // to a stack limit of 0 when all nested invocations are done and
61 // we have bottomed out. 59 // we have bottomed out.
62 isolate->SetStackLimit(saved_stack_limit_); 60 thread_->SetStackLimit(saved_stack_limit_);
63 } 61 }
64 62
65 private: 63 private:
66 Thread* thread_; 64 Thread* thread_;
67 uword saved_stack_limit_; 65 uword saved_stack_limit_;
68 }; 66 };
69 67
70 68
71 // Clears/restores Thread::long_jump_base on construction/destruction. 69 // Clears/restores Thread::long_jump_base on construction/destruction.
72 // Ensures that we do not attempt to long jump across Dart frames. 70 // Ensures that we do not attempt to long jump across Dart frames.
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 if (instance.IsClosure()) { 158 if (instance.IsClosure()) {
161 // Special case: closures are implemented with a call getter instead of a 159 // Special case: closures are implemented with a call getter instead of a
162 // call method. If the arguments didn't match, go to noSuchMethod instead 160 // call method. If the arguments didn't match, go to noSuchMethod instead
163 // of infinitely recursing on the getter. 161 // of infinitely recursing on the getter.
164 } else { 162 } else {
165 const String& getter_name = String::Handle(Symbols::New("get:call")); 163 const String& getter_name = String::Handle(Symbols::New("get:call"));
166 Class& cls = Class::Handle(instance.clazz()); 164 Class& cls = Class::Handle(instance.clazz());
167 while (!cls.IsNull()) { 165 while (!cls.IsNull()) {
168 function ^= cls.LookupDynamicFunction(getter_name); 166 function ^= cls.LookupDynamicFunction(getter_name);
169 if (!function.IsNull()) { 167 if (!function.IsNull()) {
170 Isolate* isolate = Isolate::Current(); 168 Thread* thread = Thread::Current();
171 volatile uword c_stack_pos = Isolate::GetCurrentStackPointer(); 169 Isolate* isolate = thread->isolate();
170 volatile uword c_stack_pos = Thread::GetCurrentStackPointer();
172 volatile uword c_stack_limit = OSThread::Current()->stack_base() - 171 volatile uword c_stack_limit = OSThread::Current()->stack_base() -
173 OSThread::GetSpecifiedStackSize(); 172 OSThread::GetSpecifiedStackSize();
174 #if !defined(USING_SIMULATOR) 173 #if !defined(USING_SIMULATOR)
175 ASSERT(c_stack_limit == isolate->saved_stack_limit()); 174 ASSERT(c_stack_limit == thread->saved_stack_limit());
176 #endif 175 #endif
177 176
178 if (c_stack_pos < c_stack_limit) { 177 if (c_stack_pos < c_stack_limit) {
179 const Instance& exception = 178 const Instance& exception =
180 Instance::Handle(isolate->object_store()->stack_overflow()); 179 Instance::Handle(isolate->object_store()->stack_overflow());
181 return UnhandledException::New(exception, Stacktrace::Handle()); 180 return UnhandledException::New(exception, Stacktrace::Handle());
182 } 181 }
183 182
184 const Array& getter_arguments = Array::Handle(Array::New(1)); 183 const Array& getter_arguments = Array::Handle(Array::New(1));
185 getter_arguments.SetAt(0, instance); 184 getter_arguments.SetAt(0, instance);
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 const Array& args = Array::Handle(Array::New(kNumArguments)); 594 const Array& args = Array::Handle(Array::New(kNumArguments));
596 args.SetAt(0, map); 595 args.SetAt(0, map);
597 args.SetAt(1, key); 596 args.SetAt(1, key);
598 args.SetAt(2, value); 597 args.SetAt(2, value);
599 const Object& result = Object::Handle(DartEntry::InvokeFunction(function, 598 const Object& result = Object::Handle(DartEntry::InvokeFunction(function,
600 args)); 599 args));
601 return result.raw(); 600 return result.raw();
602 } 601 }
603 602
604 } // namespace dart 603 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698