Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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/messages.h" | 5 #include "src/messages.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "src/api.h" | 9 #include "src/api.h" |
| 10 #include "src/execution.h" | 10 #include "src/execution.h" |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 488 namespace { | 488 namespace { |
| 489 | 489 |
| 490 // Convert the raw frames as written by Isolate::CaptureSimpleStackTrace into | 490 // Convert the raw frames as written by Isolate::CaptureSimpleStackTrace into |
| 491 // a vector of JS CallSite objects. | 491 // a vector of JS CallSite objects. |
| 492 MaybeHandle<FixedArray> GetStackFrames(Isolate* isolate, | 492 MaybeHandle<FixedArray> GetStackFrames(Isolate* isolate, |
| 493 Handle<Object> raw_stack) { | 493 Handle<Object> raw_stack) { |
| 494 DCHECK(raw_stack->IsJSArray()); | 494 DCHECK(raw_stack->IsJSArray()); |
| 495 Handle<JSArray> raw_stack_array = Handle<JSArray>::cast(raw_stack); | 495 Handle<JSArray> raw_stack_array = Handle<JSArray>::cast(raw_stack); |
| 496 | 496 |
| 497 DCHECK(raw_stack_array->elements()->IsFixedArray()); | 497 DCHECK(raw_stack_array->elements()->IsFixedArray()); |
| 498 Handle<FixedArray> raw_stack_elements = | 498 Handle<FrameArray> elems = |
|
Toon Verwaest
2016/08/23 13:14:08
elems(FrameArray::cast ...) as you do in other pla
jgruber
2016/08/23 15:32:13
Done.
| |
| 499 handle(FixedArray::cast(raw_stack_array->elements()), isolate); | 499 handle(FrameArray::cast(raw_stack_array->elements()), isolate); |
| 500 | 500 |
| 501 const int raw_stack_len = raw_stack_elements->length(); | 501 const int frame_count = elems->FrameCount(); |
| 502 DCHECK(raw_stack_len % 4 == 1); // Multiples of 4 plus sloppy frames count. | |
| 503 const int frame_count = (raw_stack_len - 1) / 4; | |
| 504 | 502 |
| 505 Handle<Object> sloppy_frames_obj = | 503 int sloppy_frames = Smi::cast(elems->get(0))->value(); |
|
Toon Verwaest
2016/08/23 13:14:08
This should probably be a proper elems->sloppy_fra
jgruber
2016/08/23 15:32:13
Done, but replacing sloppy_frames by an addition f
| |
| 506 FixedArray::get(*raw_stack_elements, 0, isolate); | |
| 507 int sloppy_frames = Handle<Smi>::cast(sloppy_frames_obj)->value(); | |
| 508 | 504 |
| 509 int dst_ix = 0; | |
| 510 Handle<FixedArray> frames = isolate->factory()->NewFixedArray(frame_count); | 505 Handle<FixedArray> frames = isolate->factory()->NewFixedArray(frame_count); |
| 511 for (int i = 1; i < raw_stack_len; i += 4) { | 506 for (int i = 0; i < frame_count; i++) { |
| 512 Handle<Object> recv = FixedArray::get(*raw_stack_elements, i, isolate); | 507 Handle<AbstractCode> code = handle(elems->Code(i), isolate); |
|
Toon Verwaest
2016/08/23 13:14:08
Handle<Abstractcode> code(elems->Code(i), isolate)
jgruber
2016/08/23 15:32:13
Done.
| |
| 513 Handle<Object> fun = FixedArray::get(*raw_stack_elements, i + 1, isolate); | 508 Handle<Smi> pc = handle(elems->Offset(i), isolate); |
| 514 Handle<AbstractCode> code = Handle<AbstractCode>::cast( | |
| 515 FixedArray::get(*raw_stack_elements, i + 2, isolate)); | |
| 516 Handle<Smi> pc = | |
| 517 Handle<Smi>::cast(FixedArray::get(*raw_stack_elements, i + 3, isolate)); | |
| 518 | |
| 519 Handle<Object> pos = | |
| 520 (fun->IsSmi() && pc->value() < 0) | |
| 521 ? handle(Smi::FromInt(-1 - pc->value()), isolate) | |
| 522 : handle(Smi::FromInt(code->SourcePosition(pc->value())), isolate); | |
| 523 | 509 |
| 524 sloppy_frames--; | 510 sloppy_frames--; |
| 525 Handle<Object> strict = isolate->factory()->ToBoolean(sloppy_frames < 0); | 511 Handle<Object> strict = isolate->factory()->ToBoolean(sloppy_frames < 0); |
| 526 | 512 |
| 527 Handle<Object> callsite; | 513 if (elems->IsWasmFrame(i)) { |
| 528 ASSIGN_RETURN_ON_EXCEPTION( | 514 Handle<Object> wasm_obj = handle(elems->WasmObject(i), isolate); |
| 529 isolate, callsite, | 515 Handle<Smi> wasm_fun_ix = handle(elems->WasmFunctionIndex(i), isolate); |
| 530 CallSiteUtils::Construct(isolate, recv, fun, pos, strict), FixedArray); | |
| 531 | 516 |
| 532 frames->set(dst_ix++, *callsite); | 517 Handle<Object> pos = |
|
Toon Verwaest
2016/08/23 13:14:08
This should probably become something like WasmCal
jgruber
2016/08/23 15:32:13
Ack, this will happen once we have separate JS and
| |
| 518 (pc->value() < 0) | |
| 519 ? handle(Smi::FromInt(-1 - pc->value()), isolate) | |
| 520 : handle(Smi::FromInt(code->SourcePosition(pc->value())), | |
| 521 isolate); | |
| 522 | |
| 523 Handle<Object> callsite; | |
| 524 ASSIGN_RETURN_ON_EXCEPTION( | |
| 525 isolate, callsite, | |
| 526 CallSiteUtils::Construct(isolate, wasm_obj, wasm_fun_ix, pos, strict), | |
| 527 FixedArray); | |
| 528 | |
| 529 frames->set(i, *callsite); | |
| 530 } else { | |
| 531 Handle<Object> recv = handle(elems->Receiver(i), isolate); | |
| 532 Handle<Object> fun = handle(elems->Function(i), isolate); | |
| 533 | |
| 534 Handle<Object> pos = | |
| 535 handle(Smi::FromInt(code->SourcePosition(pc->value())), isolate); | |
| 536 | |
| 537 Handle<Object> callsite; | |
| 538 ASSIGN_RETURN_ON_EXCEPTION( | |
| 539 isolate, callsite, | |
| 540 CallSiteUtils::Construct(isolate, recv, fun, pos, strict), | |
| 541 FixedArray); | |
| 542 | |
| 543 frames->set(i, *callsite); | |
| 544 } | |
| 533 } | 545 } |
| 534 | 546 |
| 535 DCHECK_EQ(frame_count, dst_ix); | |
| 536 return frames; | 547 return frames; |
| 537 } | 548 } |
| 538 | 549 |
| 539 MaybeHandle<Object> AppendErrorString(Isolate* isolate, Handle<Object> error, | 550 MaybeHandle<Object> AppendErrorString(Isolate* isolate, Handle<Object> error, |
| 540 IncrementalStringBuilder* builder) { | 551 IncrementalStringBuilder* builder) { |
| 541 MaybeHandle<String> err_str = | 552 MaybeHandle<String> err_str = |
| 542 ErrorUtils::ToString(isolate, Handle<Object>::cast(error)); | 553 ErrorUtils::ToString(isolate, Handle<Object>::cast(error)); |
| 543 if (err_str.is_null()) { | 554 if (err_str.is_null()) { |
| 544 // Error.toString threw. Try to return a string representation of the thrown | 555 // Error.toString threw. Try to return a string representation of the thrown |
| 545 // exception instead. | 556 // exception instead. |
| (...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1182 builder.AppendCString(" ("); | 1193 builder.AppendCString(" ("); |
| 1183 RETURN_ON_EXCEPTION( | 1194 RETURN_ON_EXCEPTION( |
| 1184 isolate, AppendFileLocation(isolate, recv, &call_site, &builder), String); | 1195 isolate, AppendFileLocation(isolate, recv, &call_site, &builder), String); |
| 1185 builder.AppendCString(")"); | 1196 builder.AppendCString(")"); |
| 1186 | 1197 |
| 1187 RETURN_RESULT(isolate, builder.Finish(), String); | 1198 RETURN_RESULT(isolate, builder.Finish(), String); |
| 1188 } | 1199 } |
| 1189 | 1200 |
| 1190 } // namespace internal | 1201 } // namespace internal |
| 1191 } // namespace v8 | 1202 } // namespace v8 |
| OLD | NEW |