Reviewers: Michael Starzinger,

Description:
Improve handling of debug name in CompilationInfo.

[email protected]
BUG=

Please review this at https://codereview.chromium.org/1320103002/

Base URL: https://chromium.googlesource.com/v8/v8.git@master

Affected files (+13, -14 lines):
  M src/compiler.h
  M src/compiler.cc


Index: src/compiler.cc
diff --git a/src/compiler.cc b/src/compiler.cc
index 7e2ea2597815aaf4f6fee1ea7c78f3b7402aece7..008bcfe9d38b131dc51869826b74f71f150eb04d 100644
--- a/src/compiler.cc
+++ b/src/compiler.cc
@@ -156,7 +156,7 @@ CompilationInfo::CompilationInfo(const char* debug_name, Isolate* isolate,
     : CompilationInfo(nullptr, nullptr, debug_name, STUB, isolate, zone) {}

CompilationInfo::CompilationInfo(ParseInfo* parse_info, CodeStub* code_stub, - const char* code_stub_debug_name, Mode mode,
+                                 const char* debug_name, Mode mode,
                                  Isolate* isolate, Zone* zone)
     : parse_info_(parse_info),
       isolate_(isolate),
@@ -179,7 +179,7 @@ CompilationInfo::CompilationInfo(ParseInfo* parse_info, CodeStub* code_stub,
       optimization_id_(-1),
       osr_expr_stack_height_(0),
       function_type_(nullptr),
-      code_stub_debug_name_(code_stub_debug_name) {
+      debug_name_(debug_name) {
   // Parameter count is number of stack parameters.
   if (code_stub_ != NULL) {
     CodeStubDescriptor descriptor(code_stub_);
@@ -206,7 +206,7 @@ CompilationInfo::~CompilationInfo() {
 void CompilationInfo::SetStub(CodeStub* code_stub) {
   SetMode(STUB);
   code_stub_ = code_stub;
-  code_stub_debug_name_ = CodeStub::MajorName(code_stub->MajorKey());
+  debug_name_ = CodeStub::MajorName(code_stub->MajorKey());
 }


@@ -311,15 +311,15 @@ void CompilationInfo::LogDeoptCallPosition(int pc_offset, int inlining_id) {


 base::SmartArrayPointer<char> CompilationInfo::GetDebugName() const {
-  if (IsStub()) {
-    size_t len = strlen(code_stub_debug_name_) + 1;
-    base::SmartArrayPointer<char> name(new char[len]);
-    memcpy(name.get(), code_stub_debug_name_, len);
-    return name;
-  } else {
+  if (parse_info()) {
     AllowHandleDereference allow_deref;
-    return literal()->debug_name()->ToCString();
+    return parse_info()->literal()->debug_name()->ToCString();
   }
+  const char* str = debug_name_ ? debug_name_ : "unknown";
+  size_t len = strlen(str) + 1;
+  base::SmartArrayPointer<char> name(new char[len]);
+  memcpy(name.get(), str, len);
+  return name;
 }


Index: src/compiler.h
diff --git a/src/compiler.h b/src/compiler.h
index 1b17befca070fc90852fa1065e5d8bb932dfd9a3..13ba4a71f9f7d74fc0fab7bdbdd7ed44ce318dfa 100644
--- a/src/compiler.h
+++ b/src/compiler.h
@@ -135,8 +135,7 @@ class CompilationInfo {

   explicit CompilationInfo(ParseInfo* parse_info);
   CompilationInfo(CodeStub* stub, Isolate* isolate, Zone* zone);
-  CompilationInfo(const char* code_stub_debug_name, Isolate* isolate,
-                  Zone* zone);
+  CompilationInfo(const char* debug_name, Isolate* isolate, Zone* zone);
   virtual ~CompilationInfo();

   ParseInfo* parse_info() const { return parse_info_; }
@@ -433,7 +432,7 @@ class CompilationInfo {
   };

   CompilationInfo(ParseInfo* parse_info, CodeStub* code_stub,
- const char* code_stub_debug_name, Mode mode, Isolate* isolate,
+                  const char* debug_name, Mode mode, Isolate* isolate,
                   Zone* zone);

   Isolate* isolate_;
@@ -503,7 +502,7 @@ class CompilationInfo {

   Type::FunctionType* function_type_;

-  const char* code_stub_debug_name_;
+  const char* debug_name_;

   DISALLOW_COPY_AND_ASSIGN(CompilationInfo);
 };


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to