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

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

Issue 2639673003: Use a better stack bound in DartEntry::InvokeFunction (Closed)
Patch Set: asiva review Created 3 years, 11 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
« no previous file with comments | « runtime/vm/dart_entry.h ('k') | no next file » | 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 14 matching lines...) Expand all
25 const Array& arguments) { 25 const Array& arguments) {
26 ASSERT(Thread::Current()->IsMutatorThread()); 26 ASSERT(Thread::Current()->IsMutatorThread());
27 const Array& arguments_descriptor = 27 const Array& arguments_descriptor =
28 Array::Handle(ArgumentsDescriptor::New(arguments.Length())); 28 Array::Handle(ArgumentsDescriptor::New(arguments.Length()));
29 return InvokeFunction(function, arguments, arguments_descriptor); 29 return InvokeFunction(function, arguments, arguments_descriptor);
30 } 30 }
31 31
32 32
33 class ScopedIsolateStackLimits : public ValueObject { 33 class ScopedIsolateStackLimits : public ValueObject {
34 public: 34 public:
35 explicit ScopedIsolateStackLimits(Thread* thread) 35 explicit ScopedIsolateStackLimits(Thread* thread, uword current_sp)
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 = Thread::GetCurrentStackPointer();
45 if (current_sp > os_thread->stack_base()) { 44 if (current_sp > os_thread->stack_base()) {
46 os_thread->set_stack_base(current_sp); 45 os_thread->set_stack_base(current_sp);
47 } 46 }
48 // Save the Thread's current stack limit and adjust the stack 47 // Save the Thread's current stack limit and adjust the stack
49 // limit based on the thread's stack_base. 48 // limit based on the thread's stack_base.
50 ASSERT(thread->isolate() == Isolate::Current()); 49 ASSERT(thread->isolate() == Isolate::Current());
51 saved_stack_limit_ = thread->saved_stack_limit(); 50 saved_stack_limit_ = thread->saved_stack_limit();
52 thread->SetStackLimitFromStackBase(os_thread->stack_base()); 51 thread->SetStackLimitFromStackBase(os_thread->stack_base());
53 } 52 }
54 53
(...skipping 25 matching lines...) Expand all
80 thread()->set_long_jump_base(saved_long_jump_base_); 79 thread()->set_long_jump_base(saved_long_jump_base_);
81 } 80 }
82 81
83 private: 82 private:
84 LongJumpScope* saved_long_jump_base_; 83 LongJumpScope* saved_long_jump_base_;
85 }; 84 };
86 85
87 86
88 RawObject* DartEntry::InvokeFunction(const Function& function, 87 RawObject* DartEntry::InvokeFunction(const Function& function,
89 const Array& arguments, 88 const Array& arguments,
90 const Array& arguments_descriptor) { 89 const Array& arguments_descriptor,
90 uword current_sp) {
91 // Get the entrypoint corresponding to the function specified, this 91 // Get the entrypoint corresponding to the function specified, this
92 // will result in a compilation of the function if it is not already 92 // will result in a compilation of the function if it is not already
93 // compiled. 93 // compiled.
94 Thread* thread = Thread::Current(); 94 Thread* thread = Thread::Current();
95 Zone* zone = thread->zone(); 95 Zone* zone = thread->zone();
96 ASSERT(thread->IsMutatorThread()); 96 ASSERT(thread->IsMutatorThread());
97 ScopedIsolateStackLimits stack_limit(thread, current_sp);
97 if (!function.HasCode()) { 98 if (!function.HasCode()) {
98 const Error& error = 99 const Error& error =
99 Error::Handle(zone, Compiler::CompileFunction(thread, function)); 100 Error::Handle(zone, Compiler::CompileFunction(thread, function));
100 if (!error.IsNull()) { 101 if (!error.IsNull()) {
101 return error.raw(); 102 return error.raw();
102 } 103 }
103 } 104 }
104 // Now Call the invoke stub which will invoke the dart function. 105 // Now Call the invoke stub which will invoke the dart function.
105 #if !defined(TARGET_ARCH_DBC) 106 #if !defined(TARGET_ARCH_DBC)
106 invokestub entrypoint = reinterpret_cast<invokestub>( 107 invokestub entrypoint = reinterpret_cast<invokestub>(
107 StubCode::InvokeDartCode_entry()->EntryPoint()); 108 StubCode::InvokeDartCode_entry()->EntryPoint());
108 #endif 109 #endif
109 const Code& code = Code::Handle(zone, function.CurrentCode()); 110 const Code& code = Code::Handle(zone, function.CurrentCode());
110 ASSERT(!code.IsNull()); 111 ASSERT(!code.IsNull());
111 ASSERT(thread->no_callback_scope_depth() == 0); 112 ASSERT(thread->no_callback_scope_depth() == 0);
112 ScopedIsolateStackLimits stack_limit(thread);
113 SuspendLongJumpScope suspend_long_jump_scope(thread); 113 SuspendLongJumpScope suspend_long_jump_scope(thread);
114 TransitionToGenerated transition(thread); 114 TransitionToGenerated transition(thread);
115 #if defined(TARGET_ARCH_DBC) 115 #if defined(TARGET_ARCH_DBC)
116 return Simulator::Current()->Call(code, arguments_descriptor, arguments, 116 return Simulator::Current()->Call(code, arguments_descriptor, arguments,
117 thread); 117 thread);
118 #elif defined(USING_SIMULATOR) 118 #elif defined(USING_SIMULATOR)
119 return bit_copy<RawObject*, int64_t>(Simulator::Current()->Call( 119 return bit_copy<RawObject*, int64_t>(Simulator::Current()->Call(
120 reinterpret_cast<intptr_t>(entrypoint), reinterpret_cast<intptr_t>(&code), 120 reinterpret_cast<intptr_t>(entrypoint), reinterpret_cast<intptr_t>(&code),
121 reinterpret_cast<intptr_t>(&arguments_descriptor), 121 reinterpret_cast<intptr_t>(&arguments_descriptor),
122 reinterpret_cast<intptr_t>(&arguments), 122 reinterpret_cast<intptr_t>(&arguments),
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 const Array& args = Array::Handle(Array::New(kNumArguments)); 586 const Array& args = Array::Handle(Array::New(kNumArguments));
587 args.SetAt(0, map); 587 args.SetAt(0, map);
588 args.SetAt(1, key); 588 args.SetAt(1, key);
589 args.SetAt(2, value); 589 args.SetAt(2, value);
590 const Object& result = 590 const Object& result =
591 Object::Handle(DartEntry::InvokeFunction(function, args)); 591 Object::Handle(DartEntry::InvokeFunction(function, args));
592 return result.raw(); 592 return result.raw();
593 } 593 }
594 594
595 } // namespace dart 595 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/dart_entry.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698