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

Side by Side Diff: src/isolate.cc

Issue 2623773004: [wasm] Introduce WasmToInterpreterFrame (Closed)
Patch Set: Renaming 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 | « src/frames-inl.h ('k') | src/log.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 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 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 503
504 int flags = 0; 504 int flags = 0;
505 if (helper.IsStrictFrame(*fun)) flags |= FrameArray::kIsStrict; 505 if (helper.IsStrictFrame(*fun)) flags |= FrameArray::kIsStrict;
506 if (exit_frame->IsConstructor()) flags |= FrameArray::kForceConstructor; 506 if (exit_frame->IsConstructor()) flags |= FrameArray::kForceConstructor;
507 507
508 elements = FrameArray::AppendJSFrame(elements, recv, fun, 508 elements = FrameArray::AppendJSFrame(elements, recv, fun,
509 Handle<AbstractCode>::cast(code), 509 Handle<AbstractCode>::cast(code),
510 offset, flags); 510 offset, flags);
511 } break; 511 } break;
512 512
513 case StackFrame::WASM: { 513 case StackFrame::WASM_COMPILED: {
514 WasmFrame* wasm_frame = WasmFrame::cast(frame); 514 WasmCompiledFrame* wasm_frame = WasmCompiledFrame::cast(frame);
515 Handle<WasmInstanceObject> instance(wasm_frame->wasm_instance(), this); 515 Handle<WasmInstanceObject> instance(wasm_frame->wasm_instance(), this);
516 const int wasm_function_index = wasm_frame->function_index(); 516 const int wasm_function_index = wasm_frame->function_index();
517 Code* code = wasm_frame->unchecked_code(); 517 Code* code = wasm_frame->unchecked_code();
518 Handle<AbstractCode> abstract_code(AbstractCode::cast(code), this); 518 Handle<AbstractCode> abstract_code(AbstractCode::cast(code), this);
519 const int offset = 519 const int offset =
520 static_cast<int>(wasm_frame->pc() - code->instruction_start()); 520 static_cast<int>(wasm_frame->pc() - code->instruction_start());
521 521
522 int flags = 0; 522 int flags = 0;
523 if (instance->compiled_module()->is_asm_js()) { 523 if (instance->compiled_module()->is_asm_js()) {
524 flags |= FrameArray::kIsAsmJsWasmFrame; 524 flags |= FrameArray::kIsAsmJsWasmFrame;
525 if (wasm_frame->at_to_number_conversion()) { 525 if (wasm_frame->at_to_number_conversion()) {
526 flags |= FrameArray::kAsmJsAtNumberConversion; 526 flags |= FrameArray::kAsmJsAtNumberConversion;
527 } 527 }
528 } else { 528 } else {
529 flags |= FrameArray::kIsWasmFrame; 529 flags |= FrameArray::kIsWasmFrame;
530 } 530 }
531 531
532 elements = 532 elements =
533 FrameArray::AppendWasmFrame(elements, instance, wasm_function_index, 533 FrameArray::AppendWasmFrame(elements, instance, wasm_function_index,
534 abstract_code, offset, flags); 534 abstract_code, offset, flags);
535 } break; 535 } break;
536 536
537 case StackFrame::WASM_INTERPRETER_ENTRY:
538 // TODO(clemensh): Add frames.
539 break;
540
537 default: 541 default:
538 break; 542 break;
539 } 543 }
540 } 544 }
541 545
542 elements->ShrinkToFit(); 546 elements->ShrinkToFit();
543 547
544 // TODO(yangguo): Queue this structured stack trace for preprocessing on GC. 548 // TODO(yangguo): Queue this structured stack trace for preprocessing on GC.
545 return factory()->NewJSArrayWithElements(elements); 549 return factory()->NewJSArrayWithElements(elements);
546 } 550 }
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 Handle<Object> fun_name = JSFunction::GetDebugName(fun); 696 Handle<Object> fun_name = JSFunction::GetDebugName(fun);
693 JSObject::AddProperty(stack_frame, function_key_, fun_name, NONE); 697 JSObject::AddProperty(stack_frame, function_key_, fun_name, NONE);
694 } 698 }
695 699
696 // We don't have a script and hence cannot set line and col positions. 700 // We don't have a script and hence cannot set line and col positions.
697 DCHECK(!fun->shared()->script()->IsScript()); 701 DCHECK(!fun->shared()->script()->IsScript());
698 702
699 return stack_frame; 703 return stack_frame;
700 } 704 }
701 705
702 Handle<JSObject> NewStackFrameObject(WasmFrame* frame) { 706 Handle<JSObject> NewStackFrameObject(WasmCompiledFrame* frame) {
703 Handle<JSObject> stack_frame = 707 Handle<JSObject> stack_frame =
704 factory()->NewJSObject(isolate_->object_function()); 708 factory()->NewJSObject(isolate_->object_function());
705 709
706 if (!function_key_.is_null()) { 710 if (!function_key_.is_null()) {
707 Handle<WasmCompiledModule> compiled_module( 711 Handle<WasmCompiledModule> compiled_module(
708 frame->wasm_instance()->compiled_module(), isolate_); 712 frame->wasm_instance()->compiled_module(), isolate_);
709 Handle<String> name = WasmCompiledModule::GetFunctionName( 713 Handle<String> name = WasmCompiledModule::GetFunctionName(
710 isolate_, compiled_module, frame->function_index()); 714 isolate_, compiled_module, frame->function_index());
711 JSObject::AddProperty(stack_frame, function_key_, name, NONE); 715 JSObject::AddProperty(stack_frame, function_key_, name, NONE);
712 } 716 }
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
776 // Filter frames from other security contexts. 780 // Filter frames from other security contexts.
777 if (!(options & StackTrace::kExposeFramesAcrossSecurityOrigins) && 781 if (!(options & StackTrace::kExposeFramesAcrossSecurityOrigins) &&
778 !this->context()->HasSameSecurityTokenAs(fun->context())) 782 !this->context()->HasSameSecurityTokenAs(fun->context()))
779 continue; 783 continue;
780 Handle<JSObject> new_frame_obj = helper.NewStackFrameObject(frames[i]); 784 Handle<JSObject> new_frame_obj = helper.NewStackFrameObject(frames[i]);
781 stack_trace_elems->set(frames_seen, *new_frame_obj); 785 stack_trace_elems->set(frames_seen, *new_frame_obj);
782 frames_seen++; 786 frames_seen++;
783 } 787 }
784 } else { 788 } else {
785 DCHECK(frame->is_wasm()); 789 DCHECK(frame->is_wasm());
786 WasmFrame* wasm_frame = WasmFrame::cast(frame); 790 WasmCompiledFrame* wasm_frame = WasmCompiledFrame::cast(frame);
787 Handle<JSObject> new_frame_obj = helper.NewStackFrameObject(wasm_frame); 791 Handle<JSObject> new_frame_obj = helper.NewStackFrameObject(wasm_frame);
788 stack_trace_elems->set(frames_seen, *new_frame_obj); 792 stack_trace_elems->set(frames_seen, *new_frame_obj);
789 frames_seen++; 793 frames_seen++;
790 } 794 }
791 } 795 }
792 796
793 stack_trace->set_length(Smi::FromInt(frames_seen)); 797 stack_trace->set_length(Smi::FromInt(frames_seen));
794 return stack_trace; 798 return stack_trace;
795 } 799 }
796 800
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
1213 // Gather information from the handler. 1217 // Gather information from the handler.
1214 code = frame->LookupCode(); 1218 code = frame->LookupCode();
1215 handler_sp = handler->address() + StackHandlerConstants::kSize; 1219 handler_sp = handler->address() + StackHandlerConstants::kSize;
1216 offset = Smi::cast(code->handler_table()->get(0))->value(); 1220 offset = Smi::cast(code->handler_table()->get(0))->value();
1217 break; 1221 break;
1218 } 1222 }
1219 1223
1220 if (FLAG_wasm_eh_prototype) { 1224 if (FLAG_wasm_eh_prototype) {
1221 if (frame->is_wasm() && is_catchable_by_wasm(exception)) { 1225 if (frame->is_wasm() && is_catchable_by_wasm(exception)) {
1222 int stack_slots = 0; // Will contain stack slot count of frame. 1226 int stack_slots = 0; // Will contain stack slot count of frame.
1223 WasmFrame* wasm_frame = static_cast<WasmFrame*>(frame); 1227 WasmCompiledFrame* wasm_frame = static_cast<WasmCompiledFrame*>(frame);
1224 offset = wasm_frame->LookupExceptionHandlerInTable(&stack_slots); 1228 offset = wasm_frame->LookupExceptionHandlerInTable(&stack_slots);
1225 if (offset >= 0) { 1229 if (offset >= 0) {
1226 // Compute the stack pointer from the frame pointer. This ensures that 1230 // Compute the stack pointer from the frame pointer. This ensures that
1227 // argument slots on the stack are dropped as returning would. 1231 // argument slots on the stack are dropped as returning would.
1228 Address return_sp = frame->fp() + 1232 Address return_sp = frame->fp() +
1229 StandardFrameConstants::kFixedFrameSizeAboveFp - 1233 StandardFrameConstants::kFixedFrameSizeAboveFp -
1230 stack_slots * kPointerSize; 1234 stack_slots * kPointerSize;
1231 1235
1232 // Gather information from the frame. 1236 // Gather information from the frame.
1233 code = frame->LookupCode(); 1237 code = frame->LookupCode();
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
1302 } 1306 }
1303 } 1307 }
1304 1308
1305 // For JavaScript frames we are guaranteed not to find a handler. 1309 // For JavaScript frames we are guaranteed not to find a handler.
1306 if (frame->is_java_script() && catchable_by_js) { 1310 if (frame->is_java_script() && catchable_by_js) {
1307 JavaScriptFrame* js_frame = static_cast<JavaScriptFrame*>(frame); 1311 JavaScriptFrame* js_frame = static_cast<JavaScriptFrame*>(frame);
1308 offset = js_frame->LookupExceptionHandlerInTable(nullptr, nullptr); 1312 offset = js_frame->LookupExceptionHandlerInTable(nullptr, nullptr);
1309 CHECK_EQ(-1, offset); 1313 CHECK_EQ(-1, offset);
1310 } 1314 }
1311 1315
1316 // TODO(clemensh): Handle unwinding interpreted wasm frames (stored in the
1317 // WasmInterpreter C++ object).
1318
1312 RemoveMaterializedObjectsOnUnwind(frame); 1319 RemoveMaterializedObjectsOnUnwind(frame);
1313 } 1320 }
1314 1321
1315 // Handler must exist. 1322 // Handler must exist.
1316 CHECK(code != nullptr); 1323 CHECK(code != nullptr);
1317 1324
1318 // Store information to be consumed by the CEntryStub. 1325 // Store information to be consumed by the CEntryStub.
1319 thread_local_top()->pending_handler_context_ = context; 1326 thread_local_top()->pending_handler_context_ = context;
1320 thread_local_top()->pending_handler_code_ = code; 1327 thread_local_top()->pending_handler_code_ = code;
1321 thread_local_top()->pending_handler_offset_ = offset; 1328 thread_local_top()->pending_handler_offset_ = offset;
(...skipping 2334 matching lines...) Expand 10 before | Expand all | Expand 10 after
3656 // Then check whether this scope intercepts. 3663 // Then check whether this scope intercepts.
3657 if ((flag & intercept_mask_)) { 3664 if ((flag & intercept_mask_)) {
3658 intercepted_flags_ |= flag; 3665 intercepted_flags_ |= flag;
3659 return true; 3666 return true;
3660 } 3667 }
3661 return false; 3668 return false;
3662 } 3669 }
3663 3670
3664 } // namespace internal 3671 } // namespace internal
3665 } // namespace v8 3672 } // namespace v8
OLDNEW
« no previous file with comments | « src/frames-inl.h ('k') | src/log.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698