OLD | NEW |
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" |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 | 178 |
179 // static | 179 // static |
180 MaybeHandle<Object> Execution::New(Isolate* isolate, Handle<Object> constructor, | 180 MaybeHandle<Object> Execution::New(Isolate* isolate, Handle<Object> constructor, |
181 Handle<Object> new_target, int argc, | 181 Handle<Object> new_target, int argc, |
182 Handle<Object> argv[]) { | 182 Handle<Object> argv[]) { |
183 return Invoke(isolate, true, constructor, | 183 return Invoke(isolate, true, constructor, |
184 isolate->factory()->undefined_value(), argc, argv, new_target); | 184 isolate->factory()->undefined_value(), argc, argv, new_target); |
185 } | 185 } |
186 | 186 |
187 | 187 |
188 MaybeHandle<Object> Execution::TryCall(Handle<JSFunction> func, | 188 MaybeHandle<Object> Execution::TryCall(Isolate* isolate, |
| 189 Handle<Object> callable, |
189 Handle<Object> receiver, int argc, | 190 Handle<Object> receiver, int argc, |
190 Handle<Object> args[], | 191 Handle<Object> args[], |
191 MaybeHandle<Object>* exception_out) { | 192 MaybeHandle<Object>* exception_out) { |
192 bool is_termination = false; | 193 bool is_termination = false; |
193 Isolate* isolate = func->GetIsolate(); | |
194 MaybeHandle<Object> maybe_result; | 194 MaybeHandle<Object> maybe_result; |
195 if (exception_out != NULL) *exception_out = MaybeHandle<Object>(); | 195 if (exception_out != NULL) *exception_out = MaybeHandle<Object>(); |
196 // Enter a try-block while executing the JavaScript code. To avoid | 196 // Enter a try-block while executing the JavaScript code. To avoid |
197 // duplicate error printing it must be non-verbose. Also, to avoid | 197 // duplicate error printing it must be non-verbose. Also, to avoid |
198 // creating message objects during stack overflow we shouldn't | 198 // creating message objects during stack overflow we shouldn't |
199 // capture messages. | 199 // capture messages. |
200 { | 200 { |
201 v8::TryCatch catcher(reinterpret_cast<v8::Isolate*>(isolate)); | 201 v8::TryCatch catcher(reinterpret_cast<v8::Isolate*>(isolate)); |
202 catcher.SetVerbose(false); | 202 catcher.SetVerbose(false); |
203 catcher.SetCaptureMessage(false); | 203 catcher.SetCaptureMessage(false); |
204 | 204 |
205 maybe_result = Call(isolate, func, receiver, argc, args); | 205 maybe_result = Call(isolate, callable, receiver, argc, args); |
206 | 206 |
207 if (maybe_result.is_null()) { | 207 if (maybe_result.is_null()) { |
208 DCHECK(catcher.HasCaught()); | 208 DCHECK(catcher.HasCaught()); |
209 DCHECK(isolate->has_pending_exception()); | 209 DCHECK(isolate->has_pending_exception()); |
210 DCHECK(isolate->external_caught_exception()); | 210 DCHECK(isolate->external_caught_exception()); |
211 if (isolate->pending_exception() == | 211 if (isolate->pending_exception() == |
212 isolate->heap()->termination_exception()) { | 212 isolate->heap()->termination_exception()) { |
213 is_termination = true; | 213 is_termination = true; |
214 } else { | 214 } else { |
215 if (exception_out != NULL) { | 215 if (exception_out != NULL) { |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
471 } | 471 } |
472 | 472 |
473 | 473 |
474 Handle<String> Execution::GetStackTraceLine(Handle<Object> recv, | 474 Handle<String> Execution::GetStackTraceLine(Handle<Object> recv, |
475 Handle<JSFunction> fun, | 475 Handle<JSFunction> fun, |
476 Handle<Object> pos, | 476 Handle<Object> pos, |
477 Handle<Object> is_global) { | 477 Handle<Object> is_global) { |
478 Isolate* isolate = fun->GetIsolate(); | 478 Isolate* isolate = fun->GetIsolate(); |
479 Handle<Object> args[] = { recv, fun, pos, is_global }; | 479 Handle<Object> args[] = { recv, fun, pos, is_global }; |
480 MaybeHandle<Object> maybe_result = | 480 MaybeHandle<Object> maybe_result = |
481 TryCall(isolate->get_stack_trace_line_fun(), | 481 TryCall(isolate, isolate->get_stack_trace_line_fun(), |
482 isolate->factory()->undefined_value(), arraysize(args), args); | 482 isolate->factory()->undefined_value(), arraysize(args), args); |
483 Handle<Object> result; | 483 Handle<Object> result; |
484 if (!maybe_result.ToHandle(&result) || !result->IsString()) { | 484 if (!maybe_result.ToHandle(&result) || !result->IsString()) { |
485 return isolate->factory()->empty_string(); | 485 return isolate->factory()->empty_string(); |
486 } | 486 } |
487 | 487 |
488 return Handle<String>::cast(result); | 488 return Handle<String>::cast(result); |
489 } | 489 } |
490 | 490 |
491 | 491 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 | 525 |
526 isolate_->counters()->stack_interrupts()->Increment(); | 526 isolate_->counters()->stack_interrupts()->Increment(); |
527 isolate_->counters()->runtime_profiler_ticks()->Increment(); | 527 isolate_->counters()->runtime_profiler_ticks()->Increment(); |
528 isolate_->runtime_profiler()->OptimizeNow(); | 528 isolate_->runtime_profiler()->OptimizeNow(); |
529 | 529 |
530 return isolate_->heap()->undefined_value(); | 530 return isolate_->heap()->undefined_value(); |
531 } | 531 } |
532 | 532 |
533 } // namespace internal | 533 } // namespace internal |
534 } // namespace v8 | 534 } // namespace v8 |
OLD | NEW |