| 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 <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "src/arguments.h" | 9 #include "src/arguments.h" |
| 10 #include "src/ast/prettyprinter.h" | 10 #include "src/ast/prettyprinter.h" |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 // For wasm traps, the byte offset (a.k.a source position) can not be | 110 // For wasm traps, the byte offset (a.k.a source position) can not be |
| 111 // determined from relocation info, since the explicit checks for traps | 111 // determined from relocation info, since the explicit checks for traps |
| 112 // converge in one singe block which calls this runtime function. | 112 // converge in one singe block which calls this runtime function. |
| 113 // We hence pass the byte offset explicitely, and patch it into the top-most | 113 // We hence pass the byte offset explicitely, and patch it into the top-most |
| 114 // frame (a wasm frame) on the collected stack trace. | 114 // frame (a wasm frame) on the collected stack trace. |
| 115 // TODO(wasm): This implementation is temporary, see bug #5007: | 115 // TODO(wasm): This implementation is temporary, see bug #5007: |
| 116 // https://bugs.chromium.org/p/v8/issues/detail?id=5007 | 116 // https://bugs.chromium.org/p/v8/issues/detail?id=5007 |
| 117 Handle<JSObject> error = Handle<JSObject>::cast(error_obj); | 117 Handle<JSObject> error = Handle<JSObject>::cast(error_obj); |
| 118 Handle<Object> stack_trace_obj = JSReceiver::GetDataProperty( | 118 Handle<Object> stack_trace_obj = JSReceiver::GetDataProperty( |
| 119 error, isolate->factory()->stack_trace_symbol()); | 119 error, isolate->factory()->stack_trace_symbol()); |
| 120 |
| 120 // Patch the stack trace (array of <receiver, function, code, position>). | 121 // Patch the stack trace (array of <receiver, function, code, position>). |
| 121 if (stack_trace_obj->IsJSArray()) { | 122 if (stack_trace_obj->IsJSArray()) { |
| 123 using ESTF = EncodedStackTraceFrame; |
| 124 |
| 122 Handle<FixedArray> stack_elements( | 125 Handle<FixedArray> stack_elements( |
| 123 FixedArray::cast(JSArray::cast(*stack_trace_obj)->elements())); | 126 FixedArray::cast(JSArray::cast(*stack_trace_obj)->elements())); |
| 124 DCHECK_EQ(1, stack_elements->length() % 4); | 127 DCHECK_EQ(0, stack_elements->length() % ESTF::kElementsPerFrame); |
| 125 DCHECK(Code::cast(stack_elements->get(3))->kind() == Code::WASM_FUNCTION); | 128 DCHECK(Code::cast(stack_elements->get(ESTF::kCodeOffset))->kind() == |
| 126 DCHECK(stack_elements->get(4)->IsSmi() && | 129 Code::WASM_FUNCTION); |
| 127 Smi::cast(stack_elements->get(4))->value() >= 0); | 130 DCHECK(stack_elements->get(ESTF::kWasmFunctionIndexOffset)->IsSmi() && |
| 128 stack_elements->set(4, Smi::FromInt(-1 - byte_offset)); | 131 Smi::cast(stack_elements->get(ESTF::kWasmFunctionIndexOffset)) |
| 132 ->value() >= 0); |
| 133 stack_elements->set(ESTF::kOffsetOffset, Smi::FromInt(-1 - byte_offset)); |
| 129 } | 134 } |
| 135 |
| 136 // Patch the detailed stack trace (array of JSObjects with various |
| 137 // properties). |
| 130 Handle<Object> detailed_stack_trace_obj = JSReceiver::GetDataProperty( | 138 Handle<Object> detailed_stack_trace_obj = JSReceiver::GetDataProperty( |
| 131 error, isolate->factory()->detailed_stack_trace_symbol()); | 139 error, isolate->factory()->detailed_stack_trace_symbol()); |
| 132 // Patch the detailed stack trace (array of JSObjects with various | |
| 133 // properties). | |
| 134 if (detailed_stack_trace_obj->IsJSArray()) { | 140 if (detailed_stack_trace_obj->IsJSArray()) { |
| 135 Handle<FixedArray> stack_elements( | 141 Handle<FixedArray> stack_elements( |
| 136 FixedArray::cast(JSArray::cast(*detailed_stack_trace_obj)->elements())); | 142 FixedArray::cast(JSArray::cast(*detailed_stack_trace_obj)->elements())); |
| 137 DCHECK_GE(stack_elements->length(), 1); | 143 DCHECK_GE(stack_elements->length(), 1); |
| 138 Handle<JSObject> top_frame(JSObject::cast(stack_elements->get(0))); | 144 Handle<JSObject> top_frame(JSObject::cast(stack_elements->get(0))); |
| 139 Handle<String> wasm_offset_key = | 145 Handle<String> wasm_offset_key = |
| 140 isolate->factory()->InternalizeOneByteString( | 146 isolate->factory()->InternalizeOneByteString( |
| 141 STATIC_CHAR_VECTOR("column")); | 147 STATIC_CHAR_VECTOR("column")); |
| 142 LookupIterator it(top_frame, wasm_offset_key, top_frame, | 148 LookupIterator it(top_frame, wasm_offset_key, top_frame, |
| 143 LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR); | 149 LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR); |
| (...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 564 | 570 |
| 565 RUNTIME_FUNCTION(Runtime_Typeof) { | 571 RUNTIME_FUNCTION(Runtime_Typeof) { |
| 566 HandleScope scope(isolate); | 572 HandleScope scope(isolate); |
| 567 DCHECK_EQ(1, args.length()); | 573 DCHECK_EQ(1, args.length()); |
| 568 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); | 574 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
| 569 return *Object::TypeOf(isolate, object); | 575 return *Object::TypeOf(isolate, object); |
| 570 } | 576 } |
| 571 | 577 |
| 572 } // namespace internal | 578 } // namespace internal |
| 573 } // namespace v8 | 579 } // namespace v8 |
| OLD | NEW |