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

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

Issue 506933002: Keep track of stack base whenever Dart code is invoked. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/vm/isolate.h » ('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 20 matching lines...) Expand all
31 RawObject* DartEntry::InvokeFunction(const Function& function, 31 RawObject* DartEntry::InvokeFunction(const Function& function,
32 const Array& arguments, 32 const Array& arguments,
33 const Array& arguments_descriptor) { 33 const Array& arguments_descriptor) {
34 const Context& context = 34 const Context& context =
35 Context::Handle(Isolate::Current()->object_store()->empty_context()); 35 Context::Handle(Isolate::Current()->object_store()->empty_context());
36 ASSERT(context.isolate() == Isolate::Current()); 36 ASSERT(context.isolate() == Isolate::Current());
37 return InvokeFunction(function, arguments, arguments_descriptor, context); 37 return InvokeFunction(function, arguments, arguments_descriptor, context);
38 } 38 }
39 39
40 40
41 class ScopedIsolateStackLimits : public ValueObject {
42 public:
43 explicit ScopedIsolateStackLimits(Isolate* isolate)
44 : isolate_(isolate) {
45 ASSERT(isolate_ != NULL);
46 ASSERT(isolate_ == Isolate::Current());
47 uword stack_base = reinterpret_cast<uword>(this);
48 if (stack_base >= isolate_->stack_base()) {
49 isolate_->SetStackLimitFromStackBase(stack_base);
50 }
51 }
52
53 ~ScopedIsolateStackLimits() {
54 ASSERT(isolate_ == Isolate::Current());
55 uword stack_base = reinterpret_cast<uword>(this);
56 if (isolate_->stack_base() == stack_base) {
57 // Bottomed out.
58 isolate_->ClearStackLimit();
59 }
60 }
61
62 private:
63 Isolate* isolate_;
64 };
65
66
41 RawObject* DartEntry::InvokeFunction(const Function& function, 67 RawObject* DartEntry::InvokeFunction(const Function& function,
42 const Array& arguments, 68 const Array& arguments,
43 const Array& arguments_descriptor, 69 const Array& arguments_descriptor,
44 const Context& context) { 70 const Context& context) {
45 // Get the entrypoint corresponding to the function specified, this 71 // Get the entrypoint corresponding to the function specified, this
46 // will result in a compilation of the function if it is not already 72 // will result in a compilation of the function if it is not already
47 // compiled. 73 // compiled.
48 Isolate* isolate = Isolate::Current(); 74 Isolate* isolate = Isolate::Current();
49 if (!function.HasCode()) { 75 if (!function.HasCode()) {
50 const Error& error = Error::Handle( 76 const Error& error = Error::Handle(
51 isolate, Compiler::CompileFunction(isolate, function)); 77 isolate, Compiler::CompileFunction(isolate, function));
52 if (!error.IsNull()) { 78 if (!error.IsNull()) {
53 return error.raw(); 79 return error.raw();
54 } 80 }
55 } 81 }
56 // Now Call the invoke stub which will invoke the dart function. 82 // Now Call the invoke stub which will invoke the dart function.
57 invokestub entrypoint = reinterpret_cast<invokestub>( 83 invokestub entrypoint = reinterpret_cast<invokestub>(
58 isolate->stub_code()->InvokeDartCodeEntryPoint()); 84 isolate->stub_code()->InvokeDartCodeEntryPoint());
59 const Code& code = Code::Handle(isolate, function.CurrentCode()); 85 const Code& code = Code::Handle(isolate, function.CurrentCode());
60 ASSERT(!code.IsNull()); 86 ASSERT(!code.IsNull());
61 ASSERT(Isolate::Current()->no_callback_scope_depth() == 0); 87 ASSERT(Isolate::Current()->no_callback_scope_depth() == 0);
88 ScopedIsolateStackLimits stack_limit(isolate);
62 #if defined(USING_SIMULATOR) 89 #if defined(USING_SIMULATOR)
63 #if defined(ARCH_IS_64_BIT) 90 #if defined(ARCH_IS_64_BIT)
64 // TODO(zra): Change to intptr_t so we have only one case. 91 // TODO(zra): Change to intptr_t so we have only one case.
65 return bit_copy<RawObject*, int64_t>(Simulator::Current()->Call( 92 return bit_copy<RawObject*, int64_t>(Simulator::Current()->Call(
66 reinterpret_cast<int64_t>(entrypoint), 93 reinterpret_cast<int64_t>(entrypoint),
67 static_cast<int64_t>(code.EntryPoint()), 94 static_cast<int64_t>(code.EntryPoint()),
68 reinterpret_cast<int64_t>(&arguments_descriptor), 95 reinterpret_cast<int64_t>(&arguments_descriptor),
69 reinterpret_cast<int64_t>(&arguments), 96 reinterpret_cast<int64_t>(&arguments),
70 reinterpret_cast<int64_t>(&context))); 97 reinterpret_cast<int64_t>(&context)));
71 #else 98 #else
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 const Array& args = Array::Handle(Array::New(kNumArguments)); 508 const Array& args = Array::Handle(Array::New(kNumArguments));
482 args.SetAt(0, map); 509 args.SetAt(0, map);
483 args.SetAt(1, key); 510 args.SetAt(1, key);
484 args.SetAt(2, value); 511 args.SetAt(2, value);
485 const Object& result = Object::Handle(DartEntry::InvokeFunction(function, 512 const Object& result = Object::Handle(DartEntry::InvokeFunction(function,
486 args)); 513 args));
487 return result.raw(); 514 return result.raw();
488 } 515 }
489 516
490 } // namespace dart 517 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/isolate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698