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

Side by Side Diff: src/execution.cc

Issue 430503007: Rename ASSERT* to DCHECK*. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: REBASE and fixes Created 6 years, 4 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 | « src/elements-kind.cc ('k') | src/extensions/externalize-string-extension.cc » ('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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/execution.h" 5 #include "src/execution.h"
6 6
7 #include "src/bootstrapper.h" 7 #include "src/bootstrapper.h"
8 #include "src/codegen.h" 8 #include "src/codegen.h"
9 #include "src/deoptimizer.h" 9 #include "src/deoptimizer.h"
10 #include "src/isolate-inl.h" 10 #include "src/isolate-inl.h"
11 #include "src/vm-state-inl.h" 11 #include "src/vm-state-inl.h"
12 12
13 namespace v8 { 13 namespace v8 {
14 namespace internal { 14 namespace internal {
15 15
16 StackGuard::StackGuard() 16 StackGuard::StackGuard()
17 : isolate_(NULL) { 17 : isolate_(NULL) {
18 } 18 }
19 19
20 20
21 void StackGuard::set_interrupt_limits(const ExecutionAccess& lock) { 21 void StackGuard::set_interrupt_limits(const ExecutionAccess& lock) {
22 ASSERT(isolate_ != NULL); 22 DCHECK(isolate_ != NULL);
23 thread_local_.jslimit_ = kInterruptLimit; 23 thread_local_.jslimit_ = kInterruptLimit;
24 thread_local_.climit_ = kInterruptLimit; 24 thread_local_.climit_ = kInterruptLimit;
25 isolate_->heap()->SetStackLimits(); 25 isolate_->heap()->SetStackLimits();
26 } 26 }
27 27
28 28
29 void StackGuard::reset_limits(const ExecutionAccess& lock) { 29 void StackGuard::reset_limits(const ExecutionAccess& lock) {
30 ASSERT(isolate_ != NULL); 30 DCHECK(isolate_ != NULL);
31 thread_local_.jslimit_ = thread_local_.real_jslimit_; 31 thread_local_.jslimit_ = thread_local_.real_jslimit_;
32 thread_local_.climit_ = thread_local_.real_climit_; 32 thread_local_.climit_ = thread_local_.real_climit_;
33 isolate_->heap()->SetStackLimits(); 33 isolate_->heap()->SetStackLimits();
34 } 34 }
35 35
36 36
37 MUST_USE_RESULT static MaybeHandle<Object> Invoke( 37 MUST_USE_RESULT static MaybeHandle<Object> Invoke(
38 bool is_construct, 38 bool is_construct,
39 Handle<JSFunction> function, 39 Handle<JSFunction> function,
40 Handle<Object> receiver, 40 Handle<Object> receiver,
(...skipping 25 matching lines...) Expand all
66 66
67 // Convert calls on global objects to be calls on the global 67 // Convert calls on global objects to be calls on the global
68 // receiver instead to avoid having a 'this' pointer which refers 68 // receiver instead to avoid having a 'this' pointer which refers
69 // directly to a global object. 69 // directly to a global object.
70 if (receiver->IsGlobalObject()) { 70 if (receiver->IsGlobalObject()) {
71 receiver = handle(Handle<GlobalObject>::cast(receiver)->global_proxy()); 71 receiver = handle(Handle<GlobalObject>::cast(receiver)->global_proxy());
72 } 72 }
73 73
74 // Make sure that the global object of the context we're about to 74 // Make sure that the global object of the context we're about to
75 // make the current one is indeed a global object. 75 // make the current one is indeed a global object.
76 ASSERT(function->context()->global_object()->IsGlobalObject()); 76 DCHECK(function->context()->global_object()->IsGlobalObject());
77 77
78 { 78 {
79 // Save and restore context around invocation and block the 79 // Save and restore context around invocation and block the
80 // allocation of handles without explicit handle scopes. 80 // allocation of handles without explicit handle scopes.
81 SaveContext save(isolate); 81 SaveContext save(isolate);
82 SealHandleScope shs(isolate); 82 SealHandleScope shs(isolate);
83 JSEntryFunction stub_entry = FUNCTION_CAST<JSEntryFunction>(code->entry()); 83 JSEntryFunction stub_entry = FUNCTION_CAST<JSEntryFunction>(code->entry());
84 84
85 // Call the function through the right JS entry stub. 85 // Call the function through the right JS entry stub.
86 byte* function_entry = function->code()->entry(); 86 byte* function_entry = function->code()->entry();
87 JSFunction* func = *function; 87 JSFunction* func = *function;
88 Object* recv = *receiver; 88 Object* recv = *receiver;
89 Object*** argv = reinterpret_cast<Object***>(args); 89 Object*** argv = reinterpret_cast<Object***>(args);
90 value = 90 value =
91 CALL_GENERATED_CODE(stub_entry, function_entry, func, recv, argc, argv); 91 CALL_GENERATED_CODE(stub_entry, function_entry, func, recv, argc, argv);
92 } 92 }
93 93
94 #ifdef VERIFY_HEAP 94 #ifdef VERIFY_HEAP
95 value->ObjectVerify(); 95 value->ObjectVerify();
96 #endif 96 #endif
97 97
98 // Update the pending exception flag and return the value. 98 // Update the pending exception flag and return the value.
99 bool has_exception = value->IsException(); 99 bool has_exception = value->IsException();
100 ASSERT(has_exception == isolate->has_pending_exception()); 100 DCHECK(has_exception == isolate->has_pending_exception());
101 if (has_exception) { 101 if (has_exception) {
102 isolate->ReportPendingMessages(); 102 isolate->ReportPendingMessages();
103 // Reset stepping state when script exits with uncaught exception. 103 // Reset stepping state when script exits with uncaught exception.
104 if (isolate->debug()->is_active()) { 104 if (isolate->debug()->is_active()) {
105 isolate->debug()->ClearStepping(); 105 isolate->debug()->ClearStepping();
106 } 106 }
107 return MaybeHandle<Object>(); 107 return MaybeHandle<Object>();
108 } else { 108 } else {
109 isolate->clear_pending_message(); 109 isolate->clear_pending_message();
110 } 110 }
(...skipping 13 matching lines...) Expand all
124 isolate, callable, TryGetFunctionDelegate(isolate, callable), Object); 124 isolate, callable, TryGetFunctionDelegate(isolate, callable), Object);
125 } 125 }
126 Handle<JSFunction> func = Handle<JSFunction>::cast(callable); 126 Handle<JSFunction> func = Handle<JSFunction>::cast(callable);
127 127
128 // In sloppy mode, convert receiver. 128 // In sloppy mode, convert receiver.
129 if (convert_receiver && !receiver->IsJSReceiver() && 129 if (convert_receiver && !receiver->IsJSReceiver() &&
130 !func->shared()->native() && 130 !func->shared()->native() &&
131 func->shared()->strict_mode() == SLOPPY) { 131 func->shared()->strict_mode() == SLOPPY) {
132 if (receiver->IsUndefined() || receiver->IsNull()) { 132 if (receiver->IsUndefined() || receiver->IsNull()) {
133 receiver = handle(func->global_proxy()); 133 receiver = handle(func->global_proxy());
134 ASSERT(!receiver->IsJSBuiltinsObject()); 134 DCHECK(!receiver->IsJSBuiltinsObject());
135 } else { 135 } else {
136 ASSIGN_RETURN_ON_EXCEPTION( 136 ASSIGN_RETURN_ON_EXCEPTION(
137 isolate, receiver, ToObject(isolate, receiver), Object); 137 isolate, receiver, ToObject(isolate, receiver), Object);
138 } 138 }
139 } 139 }
140 140
141 return Invoke(false, func, receiver, argc, argv); 141 return Invoke(false, func, receiver, argc, argv);
142 } 142 }
143 143
144 144
(...skipping 16 matching lines...) Expand all
161 v8::TryCatch catcher; 161 v8::TryCatch catcher;
162 catcher.SetVerbose(false); 162 catcher.SetVerbose(false);
163 catcher.SetCaptureMessage(false); 163 catcher.SetCaptureMessage(false);
164 164
165 // Get isolate now, because handle might be persistent 165 // Get isolate now, because handle might be persistent
166 // and get destroyed in the next call. 166 // and get destroyed in the next call.
167 Isolate* isolate = func->GetIsolate(); 167 Isolate* isolate = func->GetIsolate();
168 MaybeHandle<Object> maybe_result = Invoke(false, func, receiver, argc, args); 168 MaybeHandle<Object> maybe_result = Invoke(false, func, receiver, argc, args);
169 169
170 if (maybe_result.is_null()) { 170 if (maybe_result.is_null()) {
171 ASSERT(catcher.HasCaught()); 171 DCHECK(catcher.HasCaught());
172 ASSERT(isolate->has_pending_exception()); 172 DCHECK(isolate->has_pending_exception());
173 ASSERT(isolate->external_caught_exception()); 173 DCHECK(isolate->external_caught_exception());
174 if (exception_out != NULL) { 174 if (exception_out != NULL) {
175 if (isolate->pending_exception() == 175 if (isolate->pending_exception() ==
176 isolate->heap()->termination_exception()) { 176 isolate->heap()->termination_exception()) {
177 *exception_out = isolate->factory()->termination_exception(); 177 *exception_out = isolate->factory()->termination_exception();
178 } else { 178 } else {
179 *exception_out = v8::Utils::OpenHandle(*catcher.Exception()); 179 *exception_out = v8::Utils::OpenHandle(*catcher.Exception());
180 } 180 }
181 } 181 }
182 isolate->OptionalRescheduleException(true); 182 isolate->OptionalRescheduleException(true);
183 } 183 }
184 184
185 ASSERT(!isolate->has_pending_exception()); 185 DCHECK(!isolate->has_pending_exception());
186 ASSERT(!isolate->external_caught_exception()); 186 DCHECK(!isolate->external_caught_exception());
187 return maybe_result; 187 return maybe_result;
188 } 188 }
189 189
190 190
191 Handle<Object> Execution::GetFunctionDelegate(Isolate* isolate, 191 Handle<Object> Execution::GetFunctionDelegate(Isolate* isolate,
192 Handle<Object> object) { 192 Handle<Object> object) {
193 ASSERT(!object->IsJSFunction()); 193 DCHECK(!object->IsJSFunction());
194 Factory* factory = isolate->factory(); 194 Factory* factory = isolate->factory();
195 195
196 // If you return a function from here, it will be called when an 196 // If you return a function from here, it will be called when an
197 // attempt is made to call the given object as a function. 197 // attempt is made to call the given object as a function.
198 198
199 // If object is a function proxy, get its handler. Iterate if necessary. 199 // If object is a function proxy, get its handler. Iterate if necessary.
200 Object* fun = *object; 200 Object* fun = *object;
201 while (fun->IsJSFunctionProxy()) { 201 while (fun->IsJSFunctionProxy()) {
202 fun = JSFunctionProxy::cast(fun)->call_trap(); 202 fun = JSFunctionProxy::cast(fun)->call_trap();
203 } 203 }
204 if (fun->IsJSFunction()) return Handle<Object>(fun, isolate); 204 if (fun->IsJSFunction()) return Handle<Object>(fun, isolate);
205 205
206 // Objects created through the API can have an instance-call handler 206 // Objects created through the API can have an instance-call handler
207 // that should be used when calling the object as a function. 207 // that should be used when calling the object as a function.
208 if (fun->IsHeapObject() && 208 if (fun->IsHeapObject() &&
209 HeapObject::cast(fun)->map()->has_instance_call_handler()) { 209 HeapObject::cast(fun)->map()->has_instance_call_handler()) {
210 return Handle<JSFunction>( 210 return Handle<JSFunction>(
211 isolate->native_context()->call_as_function_delegate()); 211 isolate->native_context()->call_as_function_delegate());
212 } 212 }
213 213
214 return factory->undefined_value(); 214 return factory->undefined_value();
215 } 215 }
216 216
217 217
218 MaybeHandle<Object> Execution::TryGetFunctionDelegate(Isolate* isolate, 218 MaybeHandle<Object> Execution::TryGetFunctionDelegate(Isolate* isolate,
219 Handle<Object> object) { 219 Handle<Object> object) {
220 ASSERT(!object->IsJSFunction()); 220 DCHECK(!object->IsJSFunction());
221 221
222 // If object is a function proxy, get its handler. Iterate if necessary. 222 // If object is a function proxy, get its handler. Iterate if necessary.
223 Object* fun = *object; 223 Object* fun = *object;
224 while (fun->IsJSFunctionProxy()) { 224 while (fun->IsJSFunctionProxy()) {
225 fun = JSFunctionProxy::cast(fun)->call_trap(); 225 fun = JSFunctionProxy::cast(fun)->call_trap();
226 } 226 }
227 if (fun->IsJSFunction()) return Handle<Object>(fun, isolate); 227 if (fun->IsJSFunction()) return Handle<Object>(fun, isolate);
228 228
229 // Objects created through the API can have an instance-call handler 229 // Objects created through the API can have an instance-call handler
230 // that should be used when calling the object as a function. 230 // that should be used when calling the object as a function.
231 if (fun->IsHeapObject() && 231 if (fun->IsHeapObject() &&
232 HeapObject::cast(fun)->map()->has_instance_call_handler()) { 232 HeapObject::cast(fun)->map()->has_instance_call_handler()) {
233 return Handle<JSFunction>( 233 return Handle<JSFunction>(
234 isolate->native_context()->call_as_function_delegate()); 234 isolate->native_context()->call_as_function_delegate());
235 } 235 }
236 236
237 // If the Object doesn't have an instance-call handler we should 237 // If the Object doesn't have an instance-call handler we should
238 // throw a non-callable exception. 238 // throw a non-callable exception.
239 i::Handle<i::Object> error_obj = isolate->factory()->NewTypeError( 239 i::Handle<i::Object> error_obj = isolate->factory()->NewTypeError(
240 "called_non_callable", i::HandleVector<i::Object>(&object, 1)); 240 "called_non_callable", i::HandleVector<i::Object>(&object, 1));
241 241
242 return isolate->Throw<Object>(error_obj); 242 return isolate->Throw<Object>(error_obj);
243 } 243 }
244 244
245 245
246 Handle<Object> Execution::GetConstructorDelegate(Isolate* isolate, 246 Handle<Object> Execution::GetConstructorDelegate(Isolate* isolate,
247 Handle<Object> object) { 247 Handle<Object> object) {
248 ASSERT(!object->IsJSFunction()); 248 DCHECK(!object->IsJSFunction());
249 249
250 // If you return a function from here, it will be called when an 250 // If you return a function from here, it will be called when an
251 // attempt is made to call the given object as a constructor. 251 // attempt is made to call the given object as a constructor.
252 252
253 // If object is a function proxies, get its handler. Iterate if necessary. 253 // If object is a function proxies, get its handler. Iterate if necessary.
254 Object* fun = *object; 254 Object* fun = *object;
255 while (fun->IsJSFunctionProxy()) { 255 while (fun->IsJSFunctionProxy()) {
256 fun = JSFunctionProxy::cast(fun)->call_trap(); 256 fun = JSFunctionProxy::cast(fun)->call_trap();
257 } 257 }
258 if (fun->IsJSFunction()) return Handle<Object>(fun, isolate); 258 if (fun->IsJSFunction()) return Handle<Object>(fun, isolate);
259 259
260 // Objects created through the API can have an instance-call handler 260 // Objects created through the API can have an instance-call handler
261 // that should be used when calling the object as a function. 261 // that should be used when calling the object as a function.
262 if (fun->IsHeapObject() && 262 if (fun->IsHeapObject() &&
263 HeapObject::cast(fun)->map()->has_instance_call_handler()) { 263 HeapObject::cast(fun)->map()->has_instance_call_handler()) {
264 return Handle<JSFunction>( 264 return Handle<JSFunction>(
265 isolate->native_context()->call_as_constructor_delegate()); 265 isolate->native_context()->call_as_constructor_delegate());
266 } 266 }
267 267
268 return isolate->factory()->undefined_value(); 268 return isolate->factory()->undefined_value();
269 } 269 }
270 270
271 271
272 MaybeHandle<Object> Execution::TryGetConstructorDelegate( 272 MaybeHandle<Object> Execution::TryGetConstructorDelegate(
273 Isolate* isolate, Handle<Object> object) { 273 Isolate* isolate, Handle<Object> object) {
274 ASSERT(!object->IsJSFunction()); 274 DCHECK(!object->IsJSFunction());
275 275
276 // If you return a function from here, it will be called when an 276 // If you return a function from here, it will be called when an
277 // attempt is made to call the given object as a constructor. 277 // attempt is made to call the given object as a constructor.
278 278
279 // If object is a function proxies, get its handler. Iterate if necessary. 279 // If object is a function proxies, get its handler. Iterate if necessary.
280 Object* fun = *object; 280 Object* fun = *object;
281 while (fun->IsJSFunctionProxy()) { 281 while (fun->IsJSFunctionProxy()) {
282 fun = JSFunctionProxy::cast(fun)->call_trap(); 282 fun = JSFunctionProxy::cast(fun)->call_trap();
283 } 283 }
284 if (fun->IsJSFunction()) return Handle<Object>(fun, isolate); 284 if (fun->IsJSFunction()) return Handle<Object>(fun, isolate);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 // Add scope to the chain. 339 // Add scope to the chain.
340 scope->prev_ = thread_local_.postpone_interrupts_; 340 scope->prev_ = thread_local_.postpone_interrupts_;
341 thread_local_.postpone_interrupts_ = scope; 341 thread_local_.postpone_interrupts_ = scope;
342 } 342 }
343 343
344 344
345 void StackGuard::PopPostponeInterruptsScope() { 345 void StackGuard::PopPostponeInterruptsScope() {
346 ExecutionAccess access(isolate_); 346 ExecutionAccess access(isolate_);
347 PostponeInterruptsScope* top = thread_local_.postpone_interrupts_; 347 PostponeInterruptsScope* top = thread_local_.postpone_interrupts_;
348 // Make intercepted interrupts active. 348 // Make intercepted interrupts active.
349 ASSERT((thread_local_.interrupt_flags_ & top->intercept_mask_) == 0); 349 DCHECK((thread_local_.interrupt_flags_ & top->intercept_mask_) == 0);
350 thread_local_.interrupt_flags_ |= top->intercepted_flags_; 350 thread_local_.interrupt_flags_ |= top->intercepted_flags_;
351 if (has_pending_interrupts(access)) set_interrupt_limits(access); 351 if (has_pending_interrupts(access)) set_interrupt_limits(access);
352 // Remove scope from chain. 352 // Remove scope from chain.
353 thread_local_.postpone_interrupts_ = top->prev_; 353 thread_local_.postpone_interrupts_ = top->prev_;
354 } 354 }
355 355
356 356
357 bool StackGuard::CheckInterrupt(InterruptFlag flag) { 357 bool StackGuard::CheckInterrupt(InterruptFlag flag) {
358 ExecutionAccess access(isolate_); 358 ExecutionAccess access(isolate_);
359 return thread_local_.interrupt_flags_ & flag; 359 return thread_local_.interrupt_flags_ & flag;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 climit_ = kIllegalLimit; 437 climit_ = kIllegalLimit;
438 postpone_interrupts_ = NULL; 438 postpone_interrupts_ = NULL;
439 interrupt_flags_ = 0; 439 interrupt_flags_ = 0;
440 } 440 }
441 441
442 442
443 bool StackGuard::ThreadLocal::Initialize(Isolate* isolate) { 443 bool StackGuard::ThreadLocal::Initialize(Isolate* isolate) {
444 bool should_set_stack_limits = false; 444 bool should_set_stack_limits = false;
445 if (real_climit_ == kIllegalLimit) { 445 if (real_climit_ == kIllegalLimit) {
446 const uintptr_t kLimitSize = FLAG_stack_size * KB; 446 const uintptr_t kLimitSize = FLAG_stack_size * KB;
447 ASSERT(GetCurrentStackPosition() > kLimitSize); 447 DCHECK(GetCurrentStackPosition() > kLimitSize);
448 uintptr_t limit = GetCurrentStackPosition() - kLimitSize; 448 uintptr_t limit = GetCurrentStackPosition() - kLimitSize;
449 real_jslimit_ = SimulatorStack::JsLimitFromCLimit(isolate, limit); 449 real_jslimit_ = SimulatorStack::JsLimitFromCLimit(isolate, limit);
450 jslimit_ = SimulatorStack::JsLimitFromCLimit(isolate, limit); 450 jslimit_ = SimulatorStack::JsLimitFromCLimit(isolate, limit);
451 real_climit_ = limit; 451 real_climit_ = limit;
452 climit_ = limit; 452 climit_ = limit;
453 should_set_stack_limits = true; 453 should_set_stack_limits = true;
454 } 454 }
455 postpone_interrupts_ = NULL; 455 postpone_interrupts_ = NULL;
456 interrupt_flags_ = 0; 456 interrupt_flags_ = 0;
457 return should_set_stack_limits; 457 return should_set_stack_limits;
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 681
682 if (CheckAndClearInterrupt(TERMINATE_EXECUTION)) { 682 if (CheckAndClearInterrupt(TERMINATE_EXECUTION)) {
683 return isolate_->TerminateExecution(); 683 return isolate_->TerminateExecution();
684 } 684 }
685 685
686 if (CheckAndClearInterrupt(DEOPT_MARKED_ALLOCATION_SITES)) { 686 if (CheckAndClearInterrupt(DEOPT_MARKED_ALLOCATION_SITES)) {
687 isolate_->heap()->DeoptMarkedAllocationSites(); 687 isolate_->heap()->DeoptMarkedAllocationSites();
688 } 688 }
689 689
690 if (CheckAndClearInterrupt(INSTALL_CODE)) { 690 if (CheckAndClearInterrupt(INSTALL_CODE)) {
691 ASSERT(isolate_->concurrent_recompilation_enabled()); 691 DCHECK(isolate_->concurrent_recompilation_enabled());
692 isolate_->optimizing_compiler_thread()->InstallOptimizedFunctions(); 692 isolate_->optimizing_compiler_thread()->InstallOptimizedFunctions();
693 } 693 }
694 694
695 if (CheckAndClearInterrupt(API_INTERRUPT)) { 695 if (CheckAndClearInterrupt(API_INTERRUPT)) {
696 // Callback must be invoked outside of ExecusionAccess lock. 696 // Callback must be invoked outside of ExecusionAccess lock.
697 isolate_->InvokeApiInterruptCallback(); 697 isolate_->InvokeApiInterruptCallback();
698 } 698 }
699 699
700 isolate_->counters()->stack_interrupts()->Increment(); 700 isolate_->counters()->stack_interrupts()->Increment();
701 isolate_->counters()->runtime_profiler_ticks()->Increment(); 701 isolate_->counters()->runtime_profiler_ticks()->Increment();
702 isolate_->runtime_profiler()->OptimizeNow(); 702 isolate_->runtime_profiler()->OptimizeNow();
703 703
704 return isolate_->heap()->undefined_value(); 704 return isolate_->heap()->undefined_value();
705 } 705 }
706 706
707 } } // namespace v8::internal 707 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/elements-kind.cc ('k') | src/extensions/externalize-string-extension.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698