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

Side by Side Diff: src/messages.cc

Issue 2270783002: Add new FrameArray type (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Address comments Created 4 years, 4 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/isolate.cc ('k') | src/objects.h » ('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 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
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(FrameArray::cast(raw_stack_array->elements()));
499 handle(FixedArray::cast(raw_stack_array->elements()), isolate);
500 499
501 const int raw_stack_len = raw_stack_elements->length(); 500 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 501
505 Handle<Object> sloppy_frames_obj = 502 int sloppy_frames = elems->SloppyFrameCount();
506 FixedArray::get(*raw_stack_elements, 0, isolate);
507 int sloppy_frames = Handle<Smi>::cast(sloppy_frames_obj)->value();
508 503
509 int dst_ix = 0;
510 Handle<FixedArray> frames = isolate->factory()->NewFixedArray(frame_count); 504 Handle<FixedArray> frames = isolate->factory()->NewFixedArray(frame_count);
511 for (int i = 1; i < raw_stack_len; i += 4) { 505 for (int i = 0; i < frame_count; i++) {
512 Handle<Object> recv = FixedArray::get(*raw_stack_elements, i, isolate); 506 Handle<AbstractCode> code(elems->Code(i), isolate);
513 Handle<Object> fun = FixedArray::get(*raw_stack_elements, i + 1, isolate); 507 Handle<Smi> pc(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 508
524 sloppy_frames--; 509 sloppy_frames--;
525 Handle<Object> strict = isolate->factory()->ToBoolean(sloppy_frames < 0); 510 Handle<Object> strict = isolate->factory()->ToBoolean(sloppy_frames < 0);
526 511
527 Handle<Object> callsite; 512 if (elems->IsWasmFrame(i)) {
528 ASSIGN_RETURN_ON_EXCEPTION( 513 Handle<Object> wasm_obj(elems->WasmObject(i), isolate);
529 isolate, callsite, 514 Handle<Smi> wasm_fun_ix(elems->WasmFunctionIndex(i), isolate);
530 CallSiteUtils::Construct(isolate, recv, fun, pos, strict), FixedArray);
531 515
532 frames->set(dst_ix++, *callsite); 516 Handle<Object> pos((pc->value() < 0)
517 ? Smi::FromInt(-1 - pc->value())
518 : Smi::FromInt(code->SourcePosition(pc->value())),
519 isolate);
520
521 Handle<Object> callsite;
522 ASSIGN_RETURN_ON_EXCEPTION(
523 isolate, callsite,
524 CallSiteUtils::Construct(isolate, wasm_obj, wasm_fun_ix, pos, strict),
525 FixedArray);
526
527 frames->set(i, *callsite);
528 } else {
529 Handle<Object> recv(elems->Receiver(i), isolate);
530 Handle<Object> fun(elems->Function(i), isolate);
531 Handle<Object> pos(Smi::FromInt(code->SourcePosition(pc->value())),
532 isolate);
533
534 Handle<Object> callsite;
535 ASSIGN_RETURN_ON_EXCEPTION(
536 isolate, callsite,
537 CallSiteUtils::Construct(isolate, recv, fun, pos, strict),
538 FixedArray);
539
540 frames->set(i, *callsite);
541 }
533 } 542 }
534 543
535 DCHECK_EQ(frame_count, dst_ix);
536 return frames; 544 return frames;
537 } 545 }
538 546
539 MaybeHandle<Object> AppendErrorString(Isolate* isolate, Handle<Object> error, 547 MaybeHandle<Object> AppendErrorString(Isolate* isolate, Handle<Object> error,
540 IncrementalStringBuilder* builder) { 548 IncrementalStringBuilder* builder) {
541 MaybeHandle<String> err_str = 549 MaybeHandle<String> err_str =
542 ErrorUtils::ToString(isolate, Handle<Object>::cast(error)); 550 ErrorUtils::ToString(isolate, Handle<Object>::cast(error));
543 if (err_str.is_null()) { 551 if (err_str.is_null()) {
544 // Error.toString threw. Try to return a string representation of the thrown 552 // Error.toString threw. Try to return a string representation of the thrown
545 // exception instead. 553 // exception instead.
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after
1182 builder.AppendCString(" ("); 1190 builder.AppendCString(" (");
1183 RETURN_ON_EXCEPTION( 1191 RETURN_ON_EXCEPTION(
1184 isolate, AppendFileLocation(isolate, recv, &call_site, &builder), String); 1192 isolate, AppendFileLocation(isolate, recv, &call_site, &builder), String);
1185 builder.AppendCString(")"); 1193 builder.AppendCString(")");
1186 1194
1187 RETURN_RESULT(isolate, builder.Finish(), String); 1195 RETURN_RESULT(isolate, builder.Finish(), String);
1188 } 1196 }
1189 1197
1190 } // namespace internal 1198 } // namespace internal
1191 } // namespace v8 1199 } // namespace v8
OLDNEW
« no previous file with comments | « src/isolate.cc ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698