Chromium Code Reviews| 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/frames.h" | 5 #include "src/frames.h" |
| 6 | 6 |
| 7 #include <sstream> | 7 #include <sstream> |
| 8 | 8 |
| 9 #include "src/ast/ast.h" | 9 #include "src/ast/ast.h" |
| 10 #include "src/ast/scopeinfo.h" | 10 #include "src/ast/scopeinfo.h" |
| 11 #include "src/base/bits.h" | 11 #include "src/base/bits.h" |
| 12 #include "src/deoptimizer.h" | 12 #include "src/deoptimizer.h" |
| 13 #include "src/frames-inl.h" | 13 #include "src/frames-inl.h" |
| 14 #include "src/full-codegen/full-codegen.h" | 14 #include "src/full-codegen/full-codegen.h" |
| 15 #include "src/register-configuration.h" | 15 #include "src/register-configuration.h" |
| 16 #include "src/safepoint-table.h" | 16 #include "src/safepoint-table.h" |
| 17 #include "src/string-stream.h" | 17 #include "src/string-stream.h" |
| 18 #include "src/vm-state-inl.h" | 18 #include "src/vm-state-inl.h" |
| 19 #include "src/wasm/wasm-module.h" | |
| 19 | 20 |
| 20 namespace v8 { | 21 namespace v8 { |
| 21 namespace internal { | 22 namespace internal { |
| 22 | 23 |
| 23 ReturnAddressLocationResolver | 24 ReturnAddressLocationResolver |
| 24 StackFrame::return_address_location_resolver_ = NULL; | 25 StackFrame::return_address_location_resolver_ = NULL; |
| 25 | 26 |
| 26 | 27 |
| 27 // Iterator that supports traversing the stack handlers of a | 28 // Iterator that supports traversing the stack handlers of a |
| 28 // particular frame. Needs to know the top of the handler chain. | 29 // particular frame. Needs to know the top of the handler chain. |
| (...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 610 state->fp = fp; | 611 state->fp = fp; |
| 611 state->pc_address = ResolveReturnAddressLocation( | 612 state->pc_address = ResolveReturnAddressLocation( |
| 612 reinterpret_cast<Address*>(sp - 1 * kPCOnStackSize)); | 613 reinterpret_cast<Address*>(sp - 1 * kPCOnStackSize)); |
| 613 // The constant pool recorded in the exit frame is not associated | 614 // The constant pool recorded in the exit frame is not associated |
| 614 // with the pc in this state (the return address into a C entry | 615 // with the pc in this state (the return address into a C entry |
| 615 // stub). ComputeCallerState will retrieve the constant pool | 616 // stub). ComputeCallerState will retrieve the constant pool |
| 616 // together with the associated caller pc. | 617 // together with the associated caller pc. |
| 617 state->constant_pool_address = NULL; | 618 state->constant_pool_address = NULL; |
| 618 } | 619 } |
| 619 | 620 |
| 620 void StandardFrame::Summarize(List<FrameSummary>* functions, | |
| 621 FrameSummary::Mode mode) const { | |
| 622 DCHECK(functions->length() == 0); | |
| 623 // default implementation: no summary added | |
| 624 } | |
| 625 | |
| 626 JSFunction* StandardFrame::function() const { | |
| 627 // this default implementation is overridden by JS and WASM frames | |
| 628 return nullptr; | |
| 629 } | |
| 630 | |
| 631 Object* StandardFrame::receiver() const { | |
| 632 return isolate()->heap()->undefined_value(); | |
| 633 } | |
| 634 | |
| 635 Address StandardFrame::GetExpressionAddress(int n) const { | 621 Address StandardFrame::GetExpressionAddress(int n) const { |
| 636 const int offset = StandardFrameConstants::kExpressionsOffset; | 622 const int offset = StandardFrameConstants::kExpressionsOffset; |
| 637 return fp() + offset - n * kPointerSize; | 623 return fp() + offset - n * kPointerSize; |
| 638 } | 624 } |
| 639 | 625 |
| 640 Address InterpretedFrame::GetExpressionAddress(int n) const { | 626 Address InterpretedFrame::GetExpressionAddress(int n) const { |
| 641 const int offset = InterpreterFrameConstants::kExpressionsOffset; | 627 const int offset = InterpreterFrameConstants::kExpressionsOffset; |
| 642 return fp() + offset - n * kPointerSize; | 628 return fp() + offset - n * kPointerSize; |
| 643 } | 629 } |
| 644 | 630 |
| (...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1335 | 1321 |
| 1336 void WasmFrame::Print(StringStream* accumulator, PrintMode mode, | 1322 void WasmFrame::Print(StringStream* accumulator, PrintMode mode, |
| 1337 int index) const { | 1323 int index) const { |
| 1338 accumulator->Add("wasm frame"); | 1324 accumulator->Add("wasm frame"); |
| 1339 } | 1325 } |
| 1340 | 1326 |
| 1341 Code* WasmFrame::unchecked_code() const { | 1327 Code* WasmFrame::unchecked_code() const { |
| 1342 return static_cast<Code*>(isolate()->FindCodeObject(pc())); | 1328 return static_cast<Code*>(isolate()->FindCodeObject(pc())); |
| 1343 } | 1329 } |
| 1344 | 1330 |
| 1345 JSFunction* WasmFrame::function() const { | |
| 1346 // TODO(clemensh): generate the right JSFunctions once per wasm function and | |
| 1347 // cache them | |
| 1348 Factory* factory = isolate()->factory(); | |
| 1349 Handle<JSFunction> fun = | |
| 1350 factory->NewFunction(factory->NewStringFromAsciiChecked("<WASM>")); | |
| 1351 return *fun; | |
| 1352 } | |
| 1353 | |
| 1354 void WasmFrame::Summarize(List<FrameSummary>* functions, | |
| 1355 FrameSummary::Mode mode) const { | |
| 1356 DCHECK(functions->length() == 0); | |
| 1357 Code* code = LookupCode(); | |
| 1358 int offset = static_cast<int>(pc() - code->instruction_start()); | |
| 1359 AbstractCode* abstract_code = AbstractCode::cast(code); | |
| 1360 Handle<JSFunction> fun(function(), isolate()); | |
| 1361 FrameSummary summary(receiver(), *fun, abstract_code, offset, false); | |
| 1362 functions->Add(summary); | |
| 1363 } | |
| 1364 | |
| 1365 void WasmFrame::Iterate(ObjectVisitor* v) const { IterateCompiledFrame(v); } | 1331 void WasmFrame::Iterate(ObjectVisitor* v) const { IterateCompiledFrame(v); } |
| 1366 | 1332 |
| 1367 Address WasmFrame::GetCallerStackPointer() const { | 1333 Address WasmFrame::GetCallerStackPointer() const { |
| 1368 return fp() + ExitFrameConstants::kCallerSPOffset; | 1334 return fp() + ExitFrameConstants::kCallerSPOffset; |
| 1369 } | 1335 } |
| 1370 | 1336 |
| 1337 Object* WasmFrame::wasm_obj() { | |
| 1338 FixedArray* deopt_data = LookupCode()->deoptimization_data(); | |
| 1339 DCHECK(deopt_data->length() == 2); | |
| 1340 return deopt_data->get(0); | |
| 1341 } | |
| 1342 | |
| 1343 uint32_t WasmFrame::function_index() { | |
| 1344 FixedArray* deopt_data = LookupCode()->deoptimization_data(); | |
| 1345 DCHECK(deopt_data->length() == 2); | |
| 1346 Object* func_index_obj = deopt_data->get(1); | |
| 1347 if (func_index_obj->IsUndefined()) return static_cast<uint32_t>(-1); | |
| 1348 if (func_index_obj->IsSmi()) return Smi::cast(func_index_obj)->value(); | |
| 1349 DCHECK(func_index_obj->IsHeapNumber()); | |
| 1350 uint32_t val = static_cast<uint32_t>(-1); | |
| 1351 func_index_obj->ToUint32(&val); | |
| 1352 DCHECK(val != static_cast<uint32_t>(-1)); | |
| 1353 return val; | |
| 1354 } | |
| 1355 | |
| 1356 Object* WasmFrame::function_name() { | |
| 1357 Object* wasm_obj_or_string = wasm_obj(); | |
|
Yang
2016/05/04 19:02:21
is the name of this variable still accurate?
Clemens Hammacher
2016/05/05 12:29:16
No, sorry. Done.
| |
| 1358 if (wasm_obj_or_string->IsUndefined()) return wasm_obj_or_string; | |
|
Yang
2016/05/04 19:02:22
I'm curious, in which case would wasm_obj() return
Clemens Hammacher
2016/05/05 12:29:16
Just in the tests. Where it was string or undefine
| |
| 1359 Handle<JSObject> wasm = handle(JSObject::cast(wasm_obj_or_string)); | |
| 1360 return *wasm::GetWasmFunctionName(wasm, function_index()); | |
| 1361 } | |
| 1362 | |
| 1371 namespace { | 1363 namespace { |
| 1372 | 1364 |
| 1373 | 1365 |
| 1374 void PrintFunctionSource(StringStream* accumulator, SharedFunctionInfo* shared, | 1366 void PrintFunctionSource(StringStream* accumulator, SharedFunctionInfo* shared, |
| 1375 Code* code) { | 1367 Code* code) { |
| 1376 if (FLAG_max_stack_trace_source_length != 0 && code != NULL) { | 1368 if (FLAG_max_stack_trace_source_length != 0 && code != NULL) { |
| 1377 std::ostringstream os; | 1369 std::ostringstream os; |
| 1378 os << "--------- s o u r c e c o d e ---------\n" | 1370 os << "--------- s o u r c e c o d e ---------\n" |
| 1379 << SourceCodeOf(shared, FLAG_max_stack_trace_source_length) | 1371 << SourceCodeOf(shared, FLAG_max_stack_trace_source_length) |
| 1380 << "\n-----------------------------------------\n"; | 1372 << "\n-----------------------------------------\n"; |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1798 for (StackFrameIterator it(isolate); !it.done(); it.Advance()) { | 1790 for (StackFrameIterator it(isolate); !it.done(); it.Advance()) { |
| 1799 StackFrame* frame = AllocateFrameCopy(it.frame(), zone); | 1791 StackFrame* frame = AllocateFrameCopy(it.frame(), zone); |
| 1800 list.Add(frame, zone); | 1792 list.Add(frame, zone); |
| 1801 } | 1793 } |
| 1802 return list.ToVector(); | 1794 return list.ToVector(); |
| 1803 } | 1795 } |
| 1804 | 1796 |
| 1805 | 1797 |
| 1806 } // namespace internal | 1798 } // namespace internal |
| 1807 } // namespace v8 | 1799 } // namespace v8 |
| OLD | NEW |