Chromium Code Reviews| 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/runtime/runtime-utils.h" | 5 #include "src/runtime/runtime-utils.h" |
| 6 | 6 |
| 7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
| 8 #include "src/ast/prettyprinter.h" | 8 #include "src/ast/prettyprinter.h" |
| 9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
| 10 #include "src/conversions.h" | 10 #include "src/conversions.h" |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 94 SealHandleScope shs(isolate); | 94 SealHandleScope shs(isolate); |
| 95 DCHECK_LE(0, args.length()); | 95 DCHECK_LE(0, args.length()); |
| 96 return isolate->StackOverflow(); | 96 return isolate->StackOverflow(); |
| 97 } | 97 } |
| 98 | 98 |
| 99 RUNTIME_FUNCTION(Runtime_ThrowWasmError) { | 99 RUNTIME_FUNCTION(Runtime_ThrowWasmError) { |
| 100 HandleScope scope(isolate); | 100 HandleScope scope(isolate); |
| 101 DCHECK_EQ(2, args.length()); | 101 DCHECK_EQ(2, args.length()); |
| 102 CONVERT_SMI_ARG_CHECKED(message_id, 0); | 102 CONVERT_SMI_ARG_CHECKED(message_id, 0); |
| 103 CONVERT_SMI_ARG_CHECKED(byte_offset, 1); | 103 CONVERT_SMI_ARG_CHECKED(byte_offset, 1); |
| 104 USE(byte_offset); // TODO(clemensh): patch the stack trace with this offset | 104 Handle<Object> error_obj = isolate->factory()->NewError( |
| 105 Handle<Object> error = isolate->factory()->NewError( | |
| 106 static_cast<MessageTemplate::Template>(message_id)); | 105 static_cast<MessageTemplate::Template>(message_id)); |
| 107 return isolate->Throw(*error); | 106 |
| 107 // For wasm traps, the byte offset (a.k.a source position) can not be | |
| 108 // determined from relocation info, since the explicit checks for traps | |
| 109 // converge in one singe block which calls this runtime function. | |
| 110 // We hence pass the byte offset explicitely, and patch it into the top-most | |
| 111 // frame (a wasm frame) on the collected stack trace. | |
|
Yang
2016/05/11 08:22:18
I'm very hesitant to accept this hack. But since w
Clemens Hammacher
2016/05/12 07:49:39
Tracking bug #5007.
https://bugs.chromium.org/p/v8
| |
| 112 Handle<JSObject> error = Handle<JSObject>::cast(error_obj); | |
| 113 Handle<Object> stack_trace_obj = JSReceiver::GetDataProperty( | |
| 114 error, isolate->factory()->stack_trace_symbol()); | |
| 115 // Patch the stack trace (array of <receiver, function, code, position>). | |
| 116 if (stack_trace_obj->IsJSArray()) { | |
| 117 Handle<FixedArray> stack_elements( | |
| 118 FixedArray::cast(JSArray::cast(*stack_trace_obj)->elements())); | |
| 119 DCHECK_EQ(1, stack_elements->length() % 4); | |
| 120 DCHECK(Code::cast(stack_elements->get(3))->kind() == Code::WASM_FUNCTION); | |
| 121 DCHECK(stack_elements->get(4)->IsSmi() && | |
| 122 Smi::cast(stack_elements->get(4))->value() >= 0); | |
| 123 stack_elements->set(4, Smi::FromInt(-1 - byte_offset)); | |
| 124 } | |
| 125 Handle<Object> detailed_stack_trace_obj = JSReceiver::GetDataProperty( | |
| 126 error, isolate->factory()->detailed_stack_trace_symbol()); | |
| 127 // Patch the detailed stack trace (array of JSObjects with various | |
| 128 // properties). | |
| 129 if (detailed_stack_trace_obj->IsJSArray()) { | |
| 130 Handle<FixedArray> stack_elements( | |
| 131 FixedArray::cast(JSArray::cast(*detailed_stack_trace_obj)->elements())); | |
| 132 DCHECK_GE(stack_elements->length(), 1); | |
| 133 Handle<JSObject> top_frame(JSObject::cast(stack_elements->get(0))); | |
| 134 Handle<String> wasm_offset_key = | |
| 135 isolate->factory()->InternalizeOneByteString( | |
| 136 STATIC_CHAR_VECTOR("column")); | |
| 137 LookupIterator it(top_frame, wasm_offset_key, top_frame, | |
| 138 LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR); | |
| 139 if (it.IsFound()) { | |
| 140 DCHECK(JSReceiver::GetDataProperty(&it)->IsSmi()); | |
| 141 Maybe<bool> data_set = JSReceiver::SetDataProperty( | |
| 142 &it, handle(Smi::FromInt(byte_offset), isolate)); | |
| 143 DCHECK(data_set.IsJust() && data_set.FromJust() == true); | |
| 144 USE(data_set); | |
| 145 } | |
| 146 } | |
| 147 | |
| 148 return isolate->Throw(*error_obj); | |
| 108 } | 149 } |
| 109 | 150 |
| 110 RUNTIME_FUNCTION(Runtime_UnwindAndFindExceptionHandler) { | 151 RUNTIME_FUNCTION(Runtime_UnwindAndFindExceptionHandler) { |
| 111 SealHandleScope shs(isolate); | 152 SealHandleScope shs(isolate); |
| 112 DCHECK(args.length() == 0); | 153 DCHECK(args.length() == 0); |
| 113 return isolate->UnwindAndFindHandler(); | 154 return isolate->UnwindAndFindHandler(); |
| 114 } | 155 } |
| 115 | 156 |
| 116 | 157 |
| 117 RUNTIME_FUNCTION(Runtime_PromoteScheduledException) { | 158 RUNTIME_FUNCTION(Runtime_PromoteScheduledException) { |
| (...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 515 } | 556 } |
| 516 | 557 |
| 517 RUNTIME_FUNCTION(Runtime_RunMicrotasks) { | 558 RUNTIME_FUNCTION(Runtime_RunMicrotasks) { |
| 518 HandleScope scope(isolate); | 559 HandleScope scope(isolate); |
| 519 DCHECK(args.length() == 0); | 560 DCHECK(args.length() == 0); |
| 520 isolate->RunMicrotasks(); | 561 isolate->RunMicrotasks(); |
| 521 return isolate->heap()->undefined_value(); | 562 return isolate->heap()->undefined_value(); |
| 522 } | 563 } |
| 523 } // namespace internal | 564 } // namespace internal |
| 524 } // namespace v8 | 565 } // namespace v8 |
| OLD | NEW |