Reviewers: rossberg,

Message:
There are still two tests in cctest that I need to adapt and the architecture ports are still missing. But I wanted to get a first round of review before I
polish it up.

Description:
Make --always-opt also optimize toplevel code.

[email protected]

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

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

Affected files (+29, -6 lines):
  M src/factory.cc
  M src/hydrogen.cc
  M src/ia32/lithium-codegen-ia32.cc
  M test/cctest/test-api.cc
  M test/cctest/test-debug.cc
  M test/cctest/test-decls.cc
  M test/cctest/test-heap.cc
  M test/cctest/test-parsing.cc
  M test/mjsunit/debug-compile-event-newfunction.js


Index: src/factory.cc
diff --git a/src/factory.cc b/src/factory.cc
index afcc84d606601d4f21d5d75fa611b3aa48bcac50..5464ba0adc08b697045004c46bd9833f7cf7370d 100644
--- a/src/factory.cc
+++ b/src/factory.cc
@@ -5,6 +5,7 @@
 #include "src/factory.h"

 #include "src/allocation-site-scopes.h"
+#include "src/bootstrapper.h"
 #include "src/conversions.h"
 #include "src/isolate-inl.h"
 #include "src/macro-assembler.h"
@@ -1372,7 +1373,7 @@ Handle<JSFunction> Factory::NewFunctionFromSharedFunctionInfo(
   if (isolate()->use_crankshaft() &&
       FLAG_always_opt &&
       result->is_compiled() &&
-      !info->is_toplevel() &&
+      !isolate()->bootstrapper()->IsActive() &&
       info->allows_lazy_compilation() &&
       !info->optimization_disabled() &&
       !isolate()->DebuggerHasBreakPoints()) {
Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index 0290d7c6140d2693dc254481d9571b12e6888459..893c3a897b1d05c1d9207c93425dc467560d4668 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -11268,7 +11268,7 @@ void HOptimizedGraphBuilder::VisitFunctionDeclaration(

 void HOptimizedGraphBuilder::VisitModuleDeclaration(
     ModuleDeclaration* declaration) {
-  UNREACHABLE();
+  return Bailout(kModuleDeclaration);
 }


Index: src/ia32/lithium-codegen-ia32.cc
diff --git a/src/ia32/lithium-codegen-ia32.cc b/src/ia32/lithium-codegen-ia32.cc index 6762a6c6612abca46ac0c58303cb07a430a16720..6a15e4c8f22b2702812472dc937327fbdb97db36 100644
--- a/src/ia32/lithium-codegen-ia32.cc
+++ b/src/ia32/lithium-codegen-ia32.cc
@@ -256,7 +256,11 @@ bool LCodeGen::GeneratePrologue() {
     Comment(";;; Allocate local context");
     bool need_write_barrier = true;
     // Argument to NewContext is the function, which is still in edi.
-    if (heap_slots <= FastNewContextStub::kMaximumSlots) {
+    if (FLAG_harmony_scoping && info()->scope()->is_global_scope()) {
+      __ push(edi);
+      __ Push(info()->scope()->GetScopeInfo());
+      __ CallRuntime(Runtime::kNewGlobalContext, 2);
+    } else if (heap_slots <= FastNewContextStub::kMaximumSlots) {
       FastNewContextStub stub(isolate(), heap_slots);
       __ CallStub(&stub);
       // Result of FastNewContextStub is always in new space.
Index: test/cctest/test-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index c8b8900e62fac25625e6893a91d51449801f3db8..dbd1358a1448b4c69009f1c7e618a93682a50595 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -5369,7 +5369,8 @@ void TryCatchMixedNestingCheck(v8::TryCatch* try_catch) {
   CHECK_EQ(0, strcmp(*v8::String::Utf8Value(message->Get()),
                      "Uncaught Error: a"));
   CHECK_EQ(1, message->GetLineNumber());
-  CHECK_EQ(6, message->GetStartColumn());
+  // TODO(mstarzinger): Our compilers disagree about the position.
+  CHECK_EQ(i::FLAG_always_opt ? 0 : 6, message->GetStartColumn());
 }


Index: test/cctest/test-debug.cc
diff --git a/test/cctest/test-debug.cc b/test/cctest/test-debug.cc
index 6623a3ed95e7d242841615860fe5360e9242a92b..7faad1745792bae58d0313e1c420773004ba99e9 100644
--- a/test/cctest/test-debug.cc
+++ b/test/cctest/test-debug.cc
@@ -6624,6 +6624,10 @@ TEST(Backtrace) {

   v8::Debug::SetMessageHandler(BacktraceData::MessageHandler);

+ // TODO(mstarzinger): This doesn't work with --always-opt because we don't
+  // have correct source positions in optimized code. Enable once we have.
+  i::FLAG_always_opt = false;
+
   const int kBufferSize = 1000;
   uint16_t buffer[kBufferSize];
   const char* scripts_command =
Index: test/cctest/test-decls.cc
diff --git a/test/cctest/test-decls.cc b/test/cctest/test-decls.cc
index 7a826c2476c599a8a8b2b504b7430c76d955d141..c900fac25606fc8e8e80ee383af41cb8dbec98f3 100644
--- a/test/cctest/test-decls.cc
+++ b/test/cctest/test-decls.cc
@@ -652,6 +652,17 @@ TEST(CrossScriptReferencesHarmony) {
   v8::Isolate* isolate = CcTest::isolate();
   HandleScope scope(isolate);

+ // TODO(rossberg): Reparsing of top-level code does not work in the presence + // of harmony scoping and multiple scripts. This can already be reproduced
+  // without --always-opt by relying on OSR alone.
+  //
+  // ./d8 --harmony-scoping
+  //      -e "'use strict'; let a = 1;"
+ // -e "'use strict'; let b = 2; for (var i = 0; i < 100000; ++i) b++;"
+  //
+  // For now we just disable --always-opt for this test.
+  i::FLAG_always_opt = false;
+
   const char* decs[] = {
     "var x = 1; x", "x", "this.x",
     "function x() { return 1 }; x()", "x()", "this.x()",
Index: test/cctest/test-heap.cc
diff --git a/test/cctest/test-heap.cc b/test/cctest/test-heap.cc
index 22335071389bec3993d9a6ac57fd47282612d2fa..3ad60a4246840661dcc02aedc61c05e6a3e4949f 100644
--- a/test/cctest/test-heap.cc
+++ b/test/cctest/test-heap.cc
@@ -4036,6 +4036,7 @@ TEST(NextCodeLinkIsWeak) {
   Isolate* isolate = CcTest::i_isolate();
   v8::internal::Heap* heap = CcTest::heap();

+  if (i::FLAG_always_opt) return;
   if (!isolate->use_crankshaft()) return;
   HandleScope outer_scope(heap->isolate());
   Handle<Code> code;
Index: test/cctest/test-parsing.cc
diff --git a/test/cctest/test-parsing.cc b/test/cctest/test-parsing.cc
index f55a625d6b6b5ff72a18525c6ff2667d26c9025b..8e9752a840809c42c171bd41cd680a017ee206c8 100644
--- a/test/cctest/test-parsing.cc
+++ b/test/cctest/test-parsing.cc
@@ -3004,7 +3004,8 @@ TEST(UseAsmUseCount) {
              "var foo = 1;\n"
              "\"use asm\";\n"  // Only the first one counts.
              "function bar() { \"use asm\"; var baz = 1; }");
-  CHECK_EQ(2, use_counts[v8::Isolate::kUseAsm]);
+  // Optimizing will double-count because the source is parsed twice.
+  CHECK_EQ(i::FLAG_always_opt ? 4 : 2, use_counts[v8::Isolate::kUseAsm]);
 }


Index: test/mjsunit/debug-compile-event-newfunction.js
diff --git a/test/mjsunit/debug-compile-event-newfunction.js b/test/mjsunit/debug-compile-event-newfunction.js index fb43a87f77c045a05f1b4fd07ff3cd677d8f76f8..9e03b0a8a35fff63d00f28a32f069e5d7b591d92 100644
--- a/test/mjsunit/debug-compile-event-newfunction.js
+++ b/test/mjsunit/debug-compile-event-newfunction.js
@@ -61,7 +61,7 @@ function listener(event, exec_state, event_data, data) {
 Debug.setListener(listener);

 // Create a function from its body text. It will lead to an eval.
-new Function('arg1', 'return arg1 + 1;');
+var f = new Function('arg1', 'return arg1 + 1;');

 assertNull(exception, "exception in listener");



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