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

Side by Side Diff: src/isolate.cc

Issue 917743002: [V8] Use Function.name for stack frames in v8::StackTrace (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 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 | « no previous file | test/cctest/test-api.cc » ('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 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 <stdlib.h> 5 #include <stdlib.h>
6 6
7 #include <fstream> // NOLINT(readability/streams) 7 #include <fstream> // NOLINT(readability/streams)
8 #include <sstream> 8 #include <sstream>
9 9
10 #include "src/v8.h" 10 #include "src/v8.h"
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 } 484 }
485 if (options & StackTrace::kScriptName) { 485 if (options & StackTrace::kScriptName) {
486 script_name_key_ = 486 script_name_key_ =
487 factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("scriptName")); 487 factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("scriptName"));
488 } 488 }
489 if (options & StackTrace::kScriptNameOrSourceURL) { 489 if (options & StackTrace::kScriptNameOrSourceURL) {
490 script_name_or_source_url_key_ = factory()->InternalizeOneByteString( 490 script_name_or_source_url_key_ = factory()->InternalizeOneByteString(
491 STATIC_CHAR_VECTOR("scriptNameOrSourceURL")); 491 STATIC_CHAR_VECTOR("scriptNameOrSourceURL"));
492 } 492 }
493 if (options & StackTrace::kFunctionName) { 493 if (options & StackTrace::kFunctionName) {
494 display_name_ = factory()->InternalizeOneByteString(
495 STATIC_CHAR_VECTOR("displayName"));
494 function_key_ = factory()->InternalizeOneByteString( 496 function_key_ = factory()->InternalizeOneByteString(
495 STATIC_CHAR_VECTOR("functionName")); 497 STATIC_CHAR_VECTOR("functionName"));
496 } 498 }
497 if (options & StackTrace::kIsEval) { 499 if (options & StackTrace::kIsEval) {
498 eval_key_ = 500 eval_key_ =
499 factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("isEval")); 501 factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("isEval"));
500 } 502 }
501 if (options & StackTrace::kIsConstructor) { 503 if (options & StackTrace::kIsConstructor) {
502 constructor_key_ = factory()->InternalizeOneByteString( 504 constructor_key_ = factory()->InternalizeOneByteString(
503 STATIC_CHAR_VECTOR("isConstructor")); 505 STATIC_CHAR_VECTOR("isConstructor"));
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 handle(script->name(), isolate_), NONE); 549 handle(script->name(), isolate_), NONE);
548 } 550 }
549 551
550 if (!script_name_or_source_url_key_.is_null()) { 552 if (!script_name_or_source_url_key_.is_null()) {
551 Handle<Object> result = Script::GetNameOrSourceURL(script); 553 Handle<Object> result = Script::GetNameOrSourceURL(script);
552 JSObject::AddProperty(stack_frame, script_name_or_source_url_key_, result, 554 JSObject::AddProperty(stack_frame, script_name_or_source_url_key_, result,
553 NONE); 555 NONE);
554 } 556 }
555 557
556 if (!function_key_.is_null()) { 558 if (!function_key_.is_null()) {
557 Handle<Object> fun_name(fun->shared()->DebugName(), isolate_); 559 Handle<Object> display_name =
558 JSObject::AddProperty(stack_frame, function_key_, fun_name, NONE); 560 JSObject::GetDataProperty(fun, display_name_);
561 if (display_name->IsString()) {
562 JSObject::AddProperty(stack_frame, function_key_, display_name, NONE);
Yang 2015/02/12 14:25:36 Why are we storing this in a separate property, an
kozy 2015/02/12 14:46:13 In output stack frame we store display name or fun
563 } else {
564 Handle<Object> fun_name(fun->shared()->DebugName(), isolate_);
565 JSObject::AddProperty(stack_frame, function_key_, fun_name, NONE);
566 }
559 } 567 }
560 568
561 if (!eval_key_.is_null()) { 569 if (!eval_key_.is_null()) {
562 Handle<Object> is_eval = factory()->ToBoolean( 570 Handle<Object> is_eval = factory()->ToBoolean(
563 script->compilation_type() == Script::COMPILATION_TYPE_EVAL); 571 script->compilation_type() == Script::COMPILATION_TYPE_EVAL);
564 JSObject::AddProperty(stack_frame, eval_key_, is_eval, NONE); 572 JSObject::AddProperty(stack_frame, eval_key_, is_eval, NONE);
565 } 573 }
566 574
567 if (!constructor_key_.is_null()) { 575 if (!constructor_key_.is_null()) {
568 Handle<Object> is_constructor_obj = factory()->ToBoolean(is_constructor); 576 Handle<Object> is_constructor_obj = factory()->ToBoolean(is_constructor);
569 JSObject::AddProperty(stack_frame, constructor_key_, is_constructor_obj, 577 JSObject::AddProperty(stack_frame, constructor_key_, is_constructor_obj,
570 NONE); 578 NONE);
571 } 579 }
572 580
573 return stack_frame; 581 return stack_frame;
574 } 582 }
575 583
576 private: 584 private:
577 inline Factory* factory() { return isolate_->factory(); } 585 inline Factory* factory() { return isolate_->factory(); }
578 586
579 Isolate* isolate_; 587 Isolate* isolate_;
580 Handle<String> column_key_; 588 Handle<String> column_key_;
581 Handle<String> line_key_; 589 Handle<String> line_key_;
582 Handle<String> script_id_key_; 590 Handle<String> script_id_key_;
583 Handle<String> script_name_key_; 591 Handle<String> script_name_key_;
584 Handle<String> script_name_or_source_url_key_; 592 Handle<String> script_name_or_source_url_key_;
585 Handle<String> function_key_; 593 Handle<String> function_key_;
586 Handle<String> eval_key_; 594 Handle<String> eval_key_;
587 Handle<String> constructor_key_; 595 Handle<String> constructor_key_;
596 Handle<String> display_name_;
588 }; 597 };
589 598
590 599
591 Handle<JSArray> Isolate::GetDetailedFromSimpleStackTrace( 600 Handle<JSArray> Isolate::GetDetailedFromSimpleStackTrace(
592 Handle<JSObject> error_object) { 601 Handle<JSObject> error_object) {
593 Handle<Name> key = factory()->stack_trace_symbol(); 602 Handle<Name> key = factory()->stack_trace_symbol();
594 Handle<Object> property = JSObject::GetDataProperty(error_object, key); 603 Handle<Object> property = JSObject::GetDataProperty(error_object, key);
595 if (!property->IsJSArray()) return Handle<JSArray>(); 604 if (!property->IsJSArray()) return Handle<JSArray>();
596 Handle<JSArray> simple_stack_trace = Handle<JSArray>::cast(property); 605 Handle<JSArray> simple_stack_trace = Handle<JSArray>::cast(property);
597 606
(...skipping 2035 matching lines...) Expand 10 before | Expand all | Expand 10 after
2633 if (prev_ && prev_->Intercept(flag)) return true; 2642 if (prev_ && prev_->Intercept(flag)) return true;
2634 // Then check whether this scope intercepts. 2643 // Then check whether this scope intercepts.
2635 if ((flag & intercept_mask_)) { 2644 if ((flag & intercept_mask_)) {
2636 intercepted_flags_ |= flag; 2645 intercepted_flags_ |= flag;
2637 return true; 2646 return true;
2638 } 2647 }
2639 return false; 2648 return false;
2640 } 2649 }
2641 2650
2642 } } // namespace v8::internal 2651 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698