Keep more track of whether code is from the built
authorerik.corry@gmail.com <erik.corry@gmail.com@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Wed, 17 Mar 2010 08:14:59 +0000 (08:14 +0000)
committererik.corry@gmail.com <erik.corry@gmail.com@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Wed, 17 Mar 2010 08:14:59 +0000 (08:14 +0000)
in .js files in V8.  This change gets bleeding edge
a tiny bit closer to the partial snapshots branch.
Review URL: http://codereview.chromium.org/1052003

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4150 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/api.cc
src/bootstrapper.cc
src/compiler.cc
src/compiler.h
src/debug.cc
src/globals.h
src/handles.cc
test/cctest/test-compiler.cc

index af2e7ad243a6952faea1b434c8fc668e60eb836c..b2f0e03406dffc97ef71fa6271de413f7febb24c 100644 (file)
@@ -1137,8 +1137,14 @@ Local<Script> Script::New(v8::Handle<String> source,
     pre_data_impl = NULL;
   }
   i::Handle<i::JSFunction> boilerplate =
-      i::Compiler::Compile(str, name_obj, line_offset, column_offset, NULL,
-                           pre_data_impl, Utils::OpenHandle(*script_data));
+      i::Compiler::Compile(str,
+                           name_obj,
+                           line_offset,
+                           column_offset,
+                           NULL,
+                           pre_data_impl,
+                           Utils::OpenHandle(*script_data),
+                           i::NOT_NATIVES_CODE);
   has_pending_exception = boilerplate.is_null();
   EXCEPTION_BAILOUT_CHECK(Local<Script>());
   return Local<Script>(ToApi<Script>(boilerplate));
index 8df37d2e7748ae4b0654135a19e07be76ef0f005..56b185a2ce8306e2624134a684ec9d962490e0d1 100644 (file)
@@ -816,8 +816,15 @@ bool Genesis::CompileScriptCached(Vector<const char> name,
     ASSERT(source->IsAsciiRepresentation());
     Handle<String> script_name = Factory::NewStringFromUtf8(name);
     boilerplate =
-        Compiler::Compile(source, script_name, 0, 0, extension, NULL,
-                          Handle<String>::null());
+        Compiler::Compile(
+            source,
+            script_name,
+            0,
+            0,
+            extension,
+            NULL,
+            Handle<String>::null(),
+            use_runtime_context ? NATIVES_CODE : NOT_NATIVES_CODE);
     if (boilerplate.is_null()) return false;
     cache->Add(name, boilerplate);
   }
index dce881639b78deb0244d303746c81ca2f8dc86b9..11098bae98e160e5a107b03270ab745ae68c3d7f 100755 (executable)
@@ -278,7 +278,8 @@ Handle<JSFunction> Compiler::Compile(Handle<String> source,
                                      int line_offset, int column_offset,
                                      v8::Extension* extension,
                                      ScriptDataImpl* input_pre_data,
-                                     Handle<Object> script_data) {
+                                     Handle<Object> script_data,
+                                     NativesFlag natives) {
   int source_length = source->length();
   Counters::total_load_size.Increment(source_length);
   Counters::total_compile_size.Increment(source_length);
@@ -306,6 +307,9 @@ Handle<JSFunction> Compiler::Compile(Handle<String> source,
 
     // Create a script object describing the script to be compiled.
     Handle<Script> script = Factory::NewScript(source);
+    if (natives == NATIVES_CODE) {
+      script->set_type(Smi::FromInt(Script::TYPE_NATIVE));
+    }
     if (!script_name.is_null()) {
       script->set_name(*script_name);
       script->set_line_offset(Smi::FromInt(line_offset));
index 8e220e6dc01572e5b193c8e333b0629376ba8381..94924205074c94f5a1b71b9478f267540a302837 100644 (file)
@@ -237,7 +237,8 @@ class Compiler : public AllStatic {
                                     int line_offset, int column_offset,
                                     v8::Extension* extension,
                                     ScriptDataImpl* pre_data,
-                                    Handle<Object> script_data);
+                                    Handle<Object> script_data,
+                                    NativesFlag is_natives_code);
 
   // Compile a String source within a context for Eval.
   static Handle<JSFunction> CompileEval(Handle<String> source,
index 81752e64e2d10ea5228ccbcd96e8041246473e22..2a7a9c8290e4cf4f3d5fc49f615c8fc51c673925 100644 (file)
@@ -686,8 +686,14 @@ bool Debug::CompileDebuggerScript(int index) {
   bool allow_natives_syntax = FLAG_allow_natives_syntax;
   FLAG_allow_natives_syntax = true;
   Handle<JSFunction> boilerplate;
-  boilerplate = Compiler::Compile(source_code, script_name, 0, 0, NULL, NULL,
-                                  Handle<String>::null());
+  boilerplate = Compiler::Compile(source_code,
+                                  script_name,
+                                  0,
+                                  0,
+                                  NULL,
+                                  NULL,
+                                  Handle<String>::null(),
+                                  NATIVES_CODE);
   FLAG_allow_natives_syntax = allow_natives_syntax;
 
   // Silently ignore stack overflows during compilation.
index 6759a3588fc51ed3ed9e65cf1b6d86f5cbf8dc96..cb7f27ee7d235cfc2493e5ac85fe6ca4bb354ea3 100644 (file)
@@ -322,6 +322,10 @@ enum Executability { NOT_EXECUTABLE, EXECUTABLE };
 enum VisitMode { VISIT_ALL, VISIT_ALL_IN_SCAVENGE, VISIT_ONLY_STRONG };
 
 
+// Flag indicating whether code is built into the VM (one of the natives files).
+enum NativesFlag { NOT_NATIVES_CODE, NATIVES_CODE };
+
+
 // A CodeDesc describes a buffer holding instructions and relocation
 // information. The instructions start at the beginning of the buffer
 // and grow forward, the relocation information starts at the end of
index c71d92bb15afce798b8c7f8369e3270f9d6b198d..53c16a49999996f8b5c572cf29bb3dcfd3dc942a 100644 (file)
@@ -780,7 +780,7 @@ void LoadLazy(Handle<JSObject> obj, bool* pending_exception) {
     bool allow_natives_syntax = FLAG_allow_natives_syntax;
     FLAG_allow_natives_syntax = true;
     boilerplate = Compiler::Compile(source_code, script_name, 0, 0, NULL, NULL,
-                                    Handle<String>::null());
+                                    Handle<String>::null(), NATIVES_CODE);
     FLAG_allow_natives_syntax = allow_natives_syntax;
     // If the compilation failed (possibly due to stack overflows), we
     // should never enter the result in the natives cache. Instead we
index a6b537790a0fe449108afaa505919c0949b54fbd..d61a2a108c03f43030a906b36050c1403c13cf02 100644 (file)
@@ -115,8 +115,14 @@ static void SetGlobalProperty(const char* name, Object* value) {
 static Handle<JSFunction> Compile(const char* source) {
   Handle<String> source_code(Factory::NewStringFromUtf8(CStrVector(source)));
   Handle<JSFunction> boilerplate =
-      Compiler::Compile(source_code, Handle<String>(), 0, 0, NULL, NULL,
-                        Handle<String>::null());
+      Compiler::Compile(source_code,
+                        Handle<String>(),
+                        0,
+                        0,
+                        NULL,
+                        NULL,
+                        Handle<String>::null(),
+                        NOT_NATIVES_CODE);
   return Factory::NewFunctionFromBoilerplate(boilerplate,
                                              Top::global_context());
 }