OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/isolate.h" | 5 #include "src/isolate.h" |
6 | 6 |
7 #include <stdlib.h> | 7 #include <stdlib.h> |
8 | 8 |
9 #include <fstream> // NOLINT(readability/streams) | 9 #include <fstream> // NOLINT(readability/streams) |
10 #include <sstream> | 10 #include <sstream> |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 } | 419 } |
420 } | 420 } |
421 elements->set(cursor++, *recv); | 421 elements->set(cursor++, *recv); |
422 elements->set(cursor++, *fun); | 422 elements->set(cursor++, *fun); |
423 elements->set(cursor++, *abstract_code); | 423 elements->set(cursor++, *abstract_code); |
424 elements->set(cursor++, *offset); | 424 elements->set(cursor++, *offset); |
425 frames_seen++; | 425 frames_seen++; |
426 } | 426 } |
427 } break; | 427 } break; |
428 | 428 |
429 case StackFrame::BUILTIN_EXIT: { | |
430 BuiltinExitFrame* exit_frame = BuiltinExitFrame::cast(frame); | |
431 Handle<JSFunction> fun = handle(exit_frame->function(), this); | |
432 Handle<Code> code = handle(exit_frame->LookupCode(), this); | |
433 int offset = | |
434 static_cast<int>(exit_frame->pc() - code->instruction_start()); | |
435 | |
436 // For now, builtin exit frames do not pass along a receiver. | |
437 elements = MaybeGrow(this, elements, cursor, cursor + 4); | |
438 elements->set(cursor++, *factory()->undefined_value()); | |
439 elements->set(cursor++, *fun); | |
440 elements->set(cursor++, *code); | |
441 elements->set(cursor++, Smi::FromInt(offset)); | |
442 frames_seen++; | |
443 } break; | |
444 | |
445 case StackFrame::WASM: { | 429 case StackFrame::WASM: { |
446 WasmFrame* wasm_frame = WasmFrame::cast(frame); | 430 WasmFrame* wasm_frame = WasmFrame::cast(frame); |
447 Code* code = wasm_frame->unchecked_code(); | 431 Code* code = wasm_frame->unchecked_code(); |
448 Handle<AbstractCode> abstract_code = | 432 Handle<AbstractCode> abstract_code = |
449 Handle<AbstractCode>(AbstractCode::cast(code)); | 433 Handle<AbstractCode>(AbstractCode::cast(code)); |
450 int offset = | 434 int offset = |
451 static_cast<int>(wasm_frame->pc() - code->instruction_start()); | 435 static_cast<int>(wasm_frame->pc() - code->instruction_start()); |
452 elements = MaybeGrow(this, elements, cursor, cursor + 4); | 436 elements = MaybeGrow(this, elements, cursor, cursor + 4); |
453 elements->set(cursor++, wasm_frame->wasm_obj()); | 437 elements->set(cursor++, wasm_frame->wasm_obj()); |
454 elements->set(cursor++, Smi::FromInt(wasm_frame->function_index())); | 438 elements->set(cursor++, Smi::FromInt(wasm_frame->function_index())); |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
610 } | 594 } |
611 | 595 |
612 if (!constructor_key_.is_null()) { | 596 if (!constructor_key_.is_null()) { |
613 Handle<Object> is_constructor_obj = factory()->ToBoolean(is_constructor); | 597 Handle<Object> is_constructor_obj = factory()->ToBoolean(is_constructor); |
614 JSObject::AddProperty(stack_frame, constructor_key_, is_constructor_obj, | 598 JSObject::AddProperty(stack_frame, constructor_key_, is_constructor_obj, |
615 NONE); | 599 NONE); |
616 } | 600 } |
617 return stack_frame; | 601 return stack_frame; |
618 } | 602 } |
619 | 603 |
620 Handle<JSObject> NewStackFrameObject(BuiltinExitFrame* frame) { | |
621 Handle<JSObject> stack_frame = | |
622 factory()->NewJSObject(isolate_->object_function()); | |
623 Handle<JSFunction> fun = handle(frame->function(), isolate_); | |
624 if (!function_key_.is_null()) { | |
625 Handle<Object> fun_name = JSFunction::GetDebugName(fun); | |
626 JSObject::AddProperty(stack_frame, function_key_, fun_name, NONE); | |
627 } | |
628 | |
629 // We don't have a script and hence cannot set line and col positions. | |
630 DCHECK(!fun->shared()->script()->IsScript()); | |
631 | |
632 return stack_frame; | |
633 } | |
634 | |
635 Handle<JSObject> NewStackFrameObject(WasmFrame* frame) { | 604 Handle<JSObject> NewStackFrameObject(WasmFrame* frame) { |
636 Handle<JSObject> stack_frame = | 605 Handle<JSObject> stack_frame = |
637 factory()->NewJSObject(isolate_->object_function()); | 606 factory()->NewJSObject(isolate_->object_function()); |
638 | 607 |
639 if (!function_key_.is_null()) { | 608 if (!function_key_.is_null()) { |
640 Handle<String> name = wasm::GetWasmFunctionName( | 609 Handle<String> name = wasm::GetWasmFunctionName( |
641 isolate_, handle(frame->wasm_obj(), isolate_), | 610 isolate_, handle(frame->wasm_obj(), isolate_), |
642 frame->function_index()); | 611 frame->function_index()); |
643 JSObject::AddProperty(stack_frame, function_key_, name, NONE); | 612 JSObject::AddProperty(stack_frame, function_key_, name, NONE); |
644 } | 613 } |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
753 Handle<JSFunction> fun = frames[i].function(); | 722 Handle<JSFunction> fun = frames[i].function(); |
754 // Filter frames from other security contexts. | 723 // Filter frames from other security contexts. |
755 if (!(options & StackTrace::kExposeFramesAcrossSecurityOrigins) && | 724 if (!(options & StackTrace::kExposeFramesAcrossSecurityOrigins) && |
756 !this->context()->HasSameSecurityTokenAs(fun->context())) | 725 !this->context()->HasSameSecurityTokenAs(fun->context())) |
757 continue; | 726 continue; |
758 Handle<JSObject> new_frame_obj = helper.NewStackFrameObject(frames[i]); | 727 Handle<JSObject> new_frame_obj = helper.NewStackFrameObject(frames[i]); |
759 stack_trace_elems->set(frames_seen, *new_frame_obj); | 728 stack_trace_elems->set(frames_seen, *new_frame_obj); |
760 frames_seen++; | 729 frames_seen++; |
761 } | 730 } |
762 } else { | 731 } else { |
763 DCHECK(frame->is_wasm()); | |
764 WasmFrame* wasm_frame = WasmFrame::cast(frame); | 732 WasmFrame* wasm_frame = WasmFrame::cast(frame); |
765 Handle<JSObject> new_frame_obj = helper.NewStackFrameObject(wasm_frame); | 733 Handle<JSObject> new_frame_obj = helper.NewStackFrameObject(wasm_frame); |
766 stack_trace_elems->set(frames_seen, *new_frame_obj); | 734 stack_trace_elems->set(frames_seen, *new_frame_obj); |
767 frames_seen++; | 735 frames_seen++; |
768 } | 736 } |
769 } | 737 } |
770 | 738 |
771 stack_trace->set_length(Smi::FromInt(frames_seen)); | 739 stack_trace->set_length(Smi::FromInt(frames_seen)); |
772 return stack_trace; | 740 return stack_trace; |
773 } | 741 } |
(...skipping 2300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3074 // Then check whether this scope intercepts. | 3042 // Then check whether this scope intercepts. |
3075 if ((flag & intercept_mask_)) { | 3043 if ((flag & intercept_mask_)) { |
3076 intercepted_flags_ |= flag; | 3044 intercepted_flags_ |= flag; |
3077 return true; | 3045 return true; |
3078 } | 3046 } |
3079 return false; | 3047 return false; |
3080 } | 3048 } |
3081 | 3049 |
3082 } // namespace internal | 3050 } // namespace internal |
3083 } // namespace v8 | 3051 } // namespace v8 |
OLD | NEW |