Reviewers: titzer,

https://codereview.chromium.org/1309883002/diff/1/src/compiler.h
File src/compiler.h (left):

https://codereview.chromium.org/1309883002/diff/1/src/compiler.h#oldcode405
src/compiler.h:405: Handle<Code> GenerateCodeStub();
Pretty please, with a cherry on top, let's not put logic methods on
plain data-holding classes like CompilationInfo. The logic should live
in the Compiler class.

Description:
Get rid of CompilationInfo::GenerateCodeStub method.

[email protected]

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

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

Affected files (+28, -31 lines):
  M src/accessors.cc
  M src/code-stubs.cc
  M src/compiler.h
  M src/compiler.cc
  M src/debug/debug.cc
  M src/runtime/runtime-function.cc
  M src/runtime/runtime-object.cc
  M src/runtime/runtime-test.cc


Index: src/accessors.cc
diff --git a/src/accessors.cc b/src/accessors.cc
index 8d5615278bbb4f79e6ec5fad5ac7ac92717d6f2d..b18cd9967b69d6af7e8de83d65004fea70442ef4 100644
--- a/src/accessors.cc
+++ b/src/accessors.cc
@@ -977,7 +977,7 @@ void Accessors::FunctionLengthGetter(
   } else {
     // If the function isn't compiled yet, the length is not computed
     // correctly yet. Compile it now and return the right length.
-    if (Compiler::EnsureCompiled(function, KEEP_EXCEPTION)) {
+    if (Compiler::Compile(function, KEEP_EXCEPTION)) {
       length = function->shared()->length();
     }
     if (isolate->has_pending_exception()) {
Index: src/code-stubs.cc
diff --git a/src/code-stubs.cc b/src/code-stubs.cc
index 42fefce92dbe57563535fd8d25fef7c98eaddc78..e398d70ea255eaff3193cf9cd4a113a59b4ee691 100644
--- a/src/code-stubs.cc
+++ b/src/code-stubs.cc
@@ -496,15 +496,7 @@ Handle<Code> TurboFanCodeStub::GenerateCode() {
   // Just to make sure nobody calls this...
   inner->set_code(isolate()->builtins()->builtin(Builtins::kIllegal));

-  Zone zone;
-  // Build a "hybrid" CompilationInfo for a JSFunction/CodeStub pair.
-  ParseInfo parse_info(&zone, inner);
-  CompilationInfo info(&parse_info);
-  info.SetFunctionType(GetCallInterfaceDescriptor().GetFunctionType());
-  info.MarkAsContextSpecializing();
-  info.MarkAsDeoptimizationEnabled();
-  info.SetStub(this);
-  return info.GenerateCodeStub();
+  return Compiler::GetStubCode(inner, this).ToHandleChecked();
 }


Index: src/compiler.cc
diff --git a/src/compiler.cc b/src/compiler.cc
index 9ce666c911a3edb95498371c81fee474ed993121..483852ee118c6097f6700550c918aae874ff8cc7 100644
--- a/src/compiler.cc
+++ b/src/compiler.cc
@@ -302,14 +302,6 @@ void CompilationInfo::LogDeoptCallPosition(int pc_offset, int inlining_id) {
 }


-Handle<Code> CompilationInfo::GenerateCodeStub() {
-  // Run a "mini pipeline", extracted from compiler.cc.
-  CHECK(Parser::ParseStatic(parse_info()));
-  CHECK(Compiler::Analyze(parse_info()));
-  return compiler::Pipeline(this).GenerateCode();
-}
-
-
 class HOptimizedGraphBuilderWithPositions: public HOptimizedGraphBuilder {
  public:
   explicit HOptimizedGraphBuilderWithPositions(CompilationInfo* info)
@@ -940,8 +932,24 @@ MaybeHandle<Code> Compiler::GetLazyCode(Handle<JSFunction> function) {
 }


-bool Compiler::EnsureCompiled(Handle<JSFunction> function,
-                              ClearExceptionFlag flag) {
+MaybeHandle<Code> Compiler::GetStubCode(Handle<JSFunction> function,
+                                        CodeStub* stub) {
+  // Build a "hybrid" CompilationInfo for a JSFunction/CodeStub pair.
+  Zone zone;
+  ParseInfo parse_info(&zone, function);
+  CompilationInfo info(&parse_info);
+ info.SetFunctionType(stub->GetCallInterfaceDescriptor().GetFunctionType());
+  info.MarkAsContextSpecializing();
+  info.MarkAsDeoptimizationEnabled();
+  info.SetStub(stub);
+
+  // Run a "mini pipeline", extracted from compiler.cc.
+  if (!ParseAndAnalyze(&parse_info)) return MaybeHandle<Code>();
+  return compiler::Pipeline(&info).GenerateCode();
+}
+
+
+bool Compiler::Compile(Handle<JSFunction> function, ClearExceptionFlag flag) {
   if (function->is_compiled()) return true;
   MaybeHandle<Code> maybe_code = Compiler::GetLazyCode(function);
   Handle<Code> code;
Index: src/compiler.h
diff --git a/src/compiler.h b/src/compiler.h
index 8ac0eea7efb306468ea76dc8b85b0f8fffeaf454..7f7933301917c5b3311dc13a3c2d656845515ed3 100644
--- a/src/compiler.h
+++ b/src/compiler.h
@@ -402,8 +402,6 @@ class CompilationInfo {

   bool has_simple_parameters();

-  Handle<Code> GenerateCodeStub();
-
   typedef std::vector<Handle<SharedFunctionInfo>> InlinedFunctionList;
   InlinedFunctionList const& inlined_functions() const {
     return inlined_functions_;
@@ -623,9 +621,13 @@ class Compiler : public AllStatic {
       Handle<JSFunction> function);
   MUST_USE_RESULT static MaybeHandle<Code> GetLazyCode(
       Handle<JSFunction> function);
+  MUST_USE_RESULT static MaybeHandle<Code> GetStubCode(
+      Handle<JSFunction> function, CodeStub* stub);

+ static bool Compile(Handle<JSFunction> function, ClearExceptionFlag flag);
   static bool CompileDebugCode(Handle<JSFunction> function);
   static bool CompileDebugCode(Handle<SharedFunctionInfo> shared);
+  static void CompileForLiveEdit(Handle<Script> script);

   // Parser::Parse, then Compiler::Analyze.
   static bool ParseAndAnalyze(ParseInfo* info);
@@ -634,11 +636,6 @@ class Compiler : public AllStatic {
   // Adds deoptimization support, requires ParseAndAnalyze.
   static bool EnsureDeoptimizationSupport(CompilationInfo* info);

-  static bool EnsureCompiled(Handle<JSFunction> function,
-                             ClearExceptionFlag flag);
-
-  static void CompileForLiveEdit(Handle<Script> script);
-
   // Compile a String source within a context for eval.
   MUST_USE_RESULT static MaybeHandle<JSFunction> GetFunctionFromEval(
       Handle<String> source, Handle<SharedFunctionInfo> outer_info,
Index: src/debug/debug.cc
diff --git a/src/debug/debug.cc b/src/debug/debug.cc
index 52736d528ec96e73f45a0e5f6bcaf5bacf52ee67..99036d71e7e7c6df559e192591ff1d36598e35ef 100644
--- a/src/debug/debug.cc
+++ b/src/debug/debug.cc
@@ -1493,7 +1493,7 @@ bool Debug::EnsureDebugInfo(Handle<SharedFunctionInfo> shared,

   if (function.is_null()) {
     DCHECK(shared->HasDebugCode());
-  } else if (!Compiler::EnsureCompiled(function, CLEAR_EXCEPTION)) {
+  } else if (!Compiler::Compile(function, CLEAR_EXCEPTION)) {
     return false;
   }

Index: src/runtime/runtime-function.cc
diff --git a/src/runtime/runtime-function.cc b/src/runtime/runtime-function.cc index 069bd8b548cd91e927d04d7b81b951cbcb76e253..31cda72874ee10b31cc7dc7dffdd99f91779d561 100644
--- a/src/runtime/runtime-function.cc
+++ b/src/runtime/runtime-function.cc
@@ -215,7 +215,7 @@ RUNTIME_FUNCTION(Runtime_SetCode) {
   Handle<SharedFunctionInfo> source_shared(source->shared());
   RUNTIME_ASSERT(!source_shared->bound());

-  if (!Compiler::EnsureCompiled(source, KEEP_EXCEPTION)) {
+  if (!Compiler::Compile(source, KEEP_EXCEPTION)) {
     return isolate->heap()->exception();
   }

Index: src/runtime/runtime-object.cc
diff --git a/src/runtime/runtime-object.cc b/src/runtime/runtime-object.cc
index c7d4fee44f438475b10ca771d96abe91adf4dad8..a792af8154422970fa5b69bb6dd6708e23d75fc4 100644
--- a/src/runtime/runtime-object.cc
+++ b/src/runtime/runtime-object.cc
@@ -1110,7 +1110,7 @@ static Object* Runtime_NewObjectHelper(Isolate* isolate,

   // The function should be compiled for the optimization hints to be
   // available.
-  Compiler::EnsureCompiled(function, CLEAR_EXCEPTION);
+  Compiler::Compile(function, CLEAR_EXCEPTION);

   Handle<JSObject> result;
   if (site.is_null()) {
Index: src/runtime/runtime-test.cc
diff --git a/src/runtime/runtime-test.cc b/src/runtime/runtime-test.cc
index 73f6478338258fe2c9cdbfb3c0e67c7c85ce7e6b..f5dc537b4518cfd3baed0a4d6dbf4bc07fd69c16 100644
--- a/src/runtime/runtime-test.cc
+++ b/src/runtime/runtime-test.cc
@@ -400,7 +400,7 @@ RUNTIME_FUNCTION(Runtime_DisassembleFunction) {
   DCHECK(args.length() == 1);
   // Get the function and make sure it is compiled.
   CONVERT_ARG_HANDLE_CHECKED(JSFunction, func, 0);
-  if (!Compiler::EnsureCompiled(func, KEEP_EXCEPTION)) {
+  if (!Compiler::Compile(func, KEEP_EXCEPTION)) {
     return isolate->heap()->exception();
   }
   OFStream os(stdout);


--
--
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