Reviewers: Yury Semikhatsky, alph,

Message:
test will follow

Description:
Propagate bailout reason to cpu profile node.

BUG=

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

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files:
  M include/v8-profiler.h
  M src/api.cc
  M src/cpu-profiler.cc
  M src/heap-snapshot-generator.cc
  M src/heap.cc
  M src/objects-inl.h
  M src/objects.h
  M src/objects.cc
  M src/profile-generator-inl.h
  M src/profile-generator.h
  M src/profile-generator.cc


Index: include/v8-profiler.h
diff --git a/include/v8-profiler.h b/include/v8-profiler.h
index cf2834130053656f5ecd7d30d08d1f0627544d40..7ae34f75a995833e1e8073723d130b998b17455e 100644
--- a/include/v8-profiler.h
+++ b/include/v8-profiler.h
@@ -87,6 +87,11 @@ class V8EXPORT CpuProfileNode {
    */
   int GetLineNumber() const;

+  /** Returns bailout reason for the function
+    * if the optimization was disabled for it.
+    */
+  Handle<String> GetBailoutReason() const;
+
   /**
    * Returns total (self + children) execution time of the function,
    * in milliseconds, estimated by samples count.
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index d532a1f2fd8a01e2d1ef5e82295d5263017b7229..f0a21366d98065450673b669c706af0ef34ccdc1 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -7462,6 +7462,14 @@ int CpuProfileNode::GetLineNumber() const {
 }


+Handle<String> CpuProfileNode::GetBailoutReason() const {
+  i::Isolate* isolate = i::Isolate::Current();
+  IsDeadCheck(isolate, "v8::CpuProfileNode::GetBailoutReason");
+ const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this);
+  return ToApiHandle<String>(isolate->factory()->InternalizeUtf8String(
+      node->entry()->bailout_reason()));
+}
+
 double CpuProfileNode::GetTotalTime() const {
   i::Isolate* isolate = i::Isolate::Current();
   IsDeadCheck(isolate, "v8::CpuProfileNode::GetTotalTime");
Index: src/cpu-profiler.cc
diff --git a/src/cpu-profiler.cc b/src/cpu-profiler.cc
index 0a83b85f50593cf272273efe163ffe4bf1a9e3e4..a335bd7c701bcea7e32bc9580c0bb74b473d16e8 100644
--- a/src/cpu-profiler.cc
+++ b/src/cpu-profiler.cc
@@ -253,6 +253,9 @@ void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag,
     ASSERT(Script::cast(shared->script()));
     Script* script = Script::cast(shared->script());
     rec->entry->set_script_id(script->id()->value());
+    if (shared->optimization_disabled())
+      rec->entry->set_bailout_reason(
+          profiles_->GetName(shared->bailout_reason()));
   }
   rec->size = code->ExecutableSize();
   rec->shared = shared->address();
@@ -283,6 +286,9 @@ void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag,
   rec->entry->set_script_id(script->id()->value());
   rec->size = code->ExecutableSize();
   rec->shared = shared->address();
+  if (shared->optimization_disabled())
+    rec->entry->set_bailout_reason(
+        profiles_->GetName(shared->bailout_reason()));
   processor_->Enqueue(evt_rec);
 }

Index: src/heap-snapshot-generator.cc
diff --git a/src/heap-snapshot-generator.cc b/src/heap-snapshot-generator.cc
index 9f9f84a01dc3d3fb53d165e97ad7bd060d8538c9..bc1c88f2e3e71390b099e0a2a94d3bc4e7a3ced0 100644
--- a/src/heap-snapshot-generator.cc
+++ b/src/heap-snapshot-generator.cc
@@ -1187,6 +1187,9 @@ void V8HeapExplorer::ExtractSharedFunctionInfoReferences(
   SetInternalReference(obj, entry,
                        "inferred_name", shared->inferred_name(),
                        SharedFunctionInfo::kInferredNameOffset);
+  SetInternalReference(obj, entry,
+                       "bailout_reason", shared->bailout_reason(),
+                       SharedFunctionInfo::kBailoutReasonOffset);
   SetWeakReference(obj, entry,
                    1, shared->initial_map(),
                    SharedFunctionInfo::kInitialMapOffset);
Index: src/heap.cc
diff --git a/src/heap.cc b/src/heap.cc
index c2a2707602e88eb60d3d7db3921796d66f0ef3aa..29da72edd04fafaacf263ee9402e055eabe9b4f2 100644
--- a/src/heap.cc
+++ b/src/heap.cc
@@ -3625,6 +3625,7 @@ MaybeObject* Heap::AllocateSharedFunctionInfo(Object* name) {
   share->set_script(undefined_value(), SKIP_WRITE_BARRIER);
   share->set_debug_info(undefined_value(), SKIP_WRITE_BARRIER);
   share->set_inferred_name(empty_string(), SKIP_WRITE_BARRIER);
+  share->set_bailout_reason(empty_string(), SKIP_WRITE_BARRIER);
   share->set_initial_map(undefined_value(), SKIP_WRITE_BARRIER);
   share->set_ast_node_count(0);
   share->set_counters(0);
Index: src/objects-inl.h
diff --git a/src/objects-inl.h b/src/objects-inl.h
index 128dc6be2810cccfb9c5cc26e1e93e4d969ef0b0..8a8a6b35588ae0388acf5b398ccf2d10b7678658 100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -4547,6 +4547,7 @@ ACCESSORS(SharedFunctionInfo, function_data, Object, kFunctionDataOffset)
 ACCESSORS(SharedFunctionInfo, script, Object, kScriptOffset)
 ACCESSORS(SharedFunctionInfo, debug_info, Object, kDebugInfoOffset)
 ACCESSORS(SharedFunctionInfo, inferred_name, String, kInferredNameOffset)
+ACCESSORS(SharedFunctionInfo, bailout_reason, String, kBailoutReasonOffset)
 SMI_ACCESSORS(SharedFunctionInfo, ast_node_count, kAstNodeCountOffset)


Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index 2e9badbb2aa073a3eb684b201fab60cec913ec68..afa8bce451b8dd0d3b285b8afa4b144c25059549 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -9813,6 +9813,13 @@ void SharedFunctionInfo::DisableOptimization(const char* reason) {
   // non-optimizable if optimization is disabled for the shared
   // function info.
   set_optimization_disabled(true);
+  MaybeObject* reason_object =
+      Isolate::Current()->heap()->AllocateStringFromOneByte(
+          CStrVector(reason));
+  String* reason_string;
+  if (reason_object->To<String>(&reason_string)) {
+    set_bailout_reason(reason_string);
+  }
   // Code should be the lazy compilation stub or else unoptimized.  If the
   // latter, disable optimization for the code too.
ASSERT(code()->kind() == Code::FUNCTION || code()->kind() == Code::BUILTIN);
Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index d370c32a1a4375dc25763d4e0e2d6b4da82bb323..ec5a8a617ee1e632322aadc76db8dba56cc40e0c 100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -6184,6 +6184,8 @@ class SharedFunctionInfo: public HeapObject {
   // properties.
   DECL_ACCESSORS(inferred_name, String)

+  DECL_ACCESSORS(bailout_reason, String)
+
   // The function's name if it is non-empty, otherwise the inferred name.
   String* DebugName();

@@ -6379,8 +6381,8 @@ class SharedFunctionInfo: public HeapObject {
   static const int kScriptOffset = kFunctionDataOffset + kPointerSize;
   static const int kDebugInfoOffset = kScriptOffset + kPointerSize;
   static const int kInferredNameOffset = kDebugInfoOffset + kPointerSize;
-  static const int kInitialMapOffset =
-      kInferredNameOffset + kPointerSize;
+ static const int kBailoutReasonOffset = kInferredNameOffset + kPointerSize;
+  static const int kInitialMapOffset = kBailoutReasonOffset + kPointerSize;
// ast_node_count is a Smi field. It could be grouped with another Smi field
   // into a PSEUDO_SMI_ACCESSORS pair (on x64), if one becomes available.
   static const int kAstNodeCountOffset =
Index: src/profile-generator-inl.h
diff --git a/src/profile-generator-inl.h b/src/profile-generator-inl.h
index d92085ac32d1e284e84b6a6618b1c114aa217590..eca4a74ac088b53723979c506f3144259d3ab84a 100644
--- a/src/profile-generator-inl.h
+++ b/src/profile-generator-inl.h
@@ -56,7 +56,8 @@ CodeEntry::CodeEntry(Logger::LogEventsAndTags tag,
       line_number_(line_number),
       shared_id_(0),
       script_id_(v8::Script::kNoScriptId),
-      no_frame_ranges_(NULL) {
+      no_frame_ranges_(NULL),
+      bailout_reason_(kEmptyBailoutReason) {
 }


Index: src/profile-generator.cc
diff --git a/src/profile-generator.cc b/src/profile-generator.cc
index 4e2e38988a34a29b7f3331bd18532cf01c9bb131..299be557e528271a5b44b7489cef71f9ed145c07 100644
--- a/src/profile-generator.cc
+++ b/src/profile-generator.cc
@@ -133,6 +133,7 @@ size_t StringsStorage::GetUsedMemorySize() const {

 const char* const CodeEntry::kEmptyNamePrefix = "";
 const char* const CodeEntry::kEmptyResourceName = "";
+const char* const CodeEntry::kEmptyBailoutReason = "";


 CodeEntry::~CodeEntry() {
Index: src/profile-generator.h
diff --git a/src/profile-generator.h b/src/profile-generator.h
index 7861ccd81785f3670a3d609ede6321717e0d5eac..fd161deb9a04692a05817c6a754d193b43176d4f 100644
--- a/src/profile-generator.h
+++ b/src/profile-generator.h
@@ -88,6 +88,10 @@ class CodeEntry {
   INLINE(void set_shared_id(int shared_id)) { shared_id_ = shared_id; }
   INLINE(int script_id() const) { return script_id_; }
   INLINE(void set_script_id(int script_id)) { script_id_ = script_id; }
+  INLINE(void set_bailout_reason(const char* bailout_reason)) {
+    bailout_reason_ = bailout_reason;
+  }
+  INLINE(const char* bailout_reason() const) { return bailout_reason_; }

   INLINE(static bool is_js_function_tag(Logger::LogEventsAndTags tag));

@@ -105,6 +109,7 @@ class CodeEntry {

   static const char* const kEmptyNamePrefix;
   static const char* const kEmptyResourceName;
+  static const char* const kEmptyBailoutReason;

  private:
   Logger::LogEventsAndTags tag_ : 8;
@@ -116,6 +121,7 @@ class CodeEntry {
   int shared_id_;
   int script_id_;
   List<OffsetRange>* no_frame_ranges_;
+  const char* bailout_reason_;

   DISALLOW_COPY_AND_ASSIGN(CodeEntry);
 };


--
--
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/groups/opt_out.


Reply via email to