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

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

Issue 1513993004: Fix stack overflow check in InvokeClosure. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years 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
« no previous file with comments | « no previous file | tests/language/language.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 if (instance.IsClosure()) { 160 if (instance.IsClosure()) {
161 // Special case: closures are implemented with a call getter instead of a 161 // 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 162 // call method. If the arguments didn't match, go to noSuchMethod instead
163 // of infinitely recursing on the getter. 163 // of infinitely recursing on the getter.
164 } else { 164 } else {
165 const String& getter_name = String::Handle(Symbols::New("get:call")); 165 const String& getter_name = String::Handle(Symbols::New("get:call"));
166 Class& cls = Class::Handle(instance.clazz()); 166 Class& cls = Class::Handle(instance.clazz());
167 while (!cls.IsNull()) { 167 while (!cls.IsNull()) {
168 function ^= cls.LookupDynamicFunction(getter_name); 168 function ^= cls.LookupDynamicFunction(getter_name);
169 if (!function.IsNull()) { 169 if (!function.IsNull()) {
170 // Getters don't have a stack overflow check, so do one in C++. 170 Isolate* isolate = Isolate::Current();
171 uword c_stack_pos = Isolate::GetCurrentStackPointer();
172 uword c_stack_limit = OSThread::Current()->stack_base() -
173 OSThread::GetSpecifiedStackSize();
174 #if !defined(USING_SIMULATOR)
175 ASSERT(c_stack_limit == isolate->saved_stack_limit());
176 #endif
171 177
172 Isolate* isolate = Isolate::Current(); 178 if (c_stack_pos < c_stack_limit) {
173 #if defined(USING_SIMULATOR)
174 uword stack_pos = Simulator::Current()->get_register(SPREG);
175 #else
176 uword stack_pos = Isolate::GetCurrentStackPointer();
177 #endif
178 if (stack_pos < isolate->saved_stack_limit()) {
179 const Instance& exception = 179 const Instance& exception =
180 Instance::Handle(isolate->object_store()->stack_overflow()); 180 Instance::Handle(isolate->object_store()->stack_overflow());
181 return UnhandledException::New(exception, Stacktrace::Handle()); 181 return UnhandledException::New(exception, Stacktrace::Handle());
182 } 182 }
183 183
184 const Array& getter_arguments = Array::Handle(Array::New(1)); 184 const Array& getter_arguments = Array::Handle(Array::New(1));
185 getter_arguments.SetAt(0, instance); 185 getter_arguments.SetAt(0, instance);
186 const Object& getter_result = 186 const Object& getter_result =
187 Object::Handle(DartEntry::InvokeFunction(function, 187 Object::Handle(DartEntry::InvokeFunction(function,
188 getter_arguments)); 188 getter_arguments));
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 const Array& args = Array::Handle(Array::New(kNumArguments)); 592 const Array& args = Array::Handle(Array::New(kNumArguments));
593 args.SetAt(0, map); 593 args.SetAt(0, map);
594 args.SetAt(1, key); 594 args.SetAt(1, key);
595 args.SetAt(2, value); 595 args.SetAt(2, value);
596 const Object& result = Object::Handle(DartEntry::InvokeFunction(function, 596 const Object& result = Object::Handle(DartEntry::InvokeFunction(function,
597 args)); 597 args));
598 return result.raw(); 598 return result.raw();
599 } 599 }
600 600
601 } // namespace dart 601 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | tests/language/language.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698