Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Side by Side Diff: src/compiler.cc

Issue 1140673002: [V8] Added Script::is_opaque flag for embedders (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler.h ('k') | src/debug.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/compiler.h" 5 #include "src/compiler.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "src/ast-numbering.h" 9 #include "src/ast-numbering.h"
10 #include "src/bootstrapper.h" 10 #include "src/bootstrapper.h"
(...skipping 1166 matching lines...) Expand 10 before | Expand all | Expand 10 after
1177 shared_info->ResetForNewContext(isolate->heap()->global_ic_age()); 1177 shared_info->ResetForNewContext(isolate->heap()->global_ic_age());
1178 } 1178 }
1179 1179
1180 return isolate->factory()->NewFunctionFromSharedFunctionInfo( 1180 return isolate->factory()->NewFunctionFromSharedFunctionInfo(
1181 shared_info, context, NOT_TENURED); 1181 shared_info, context, NOT_TENURED);
1182 } 1182 }
1183 1183
1184 1184
1185 Handle<SharedFunctionInfo> Compiler::CompileScript( 1185 Handle<SharedFunctionInfo> Compiler::CompileScript(
1186 Handle<String> source, Handle<Object> script_name, int line_offset, 1186 Handle<String> source, Handle<Object> script_name, int line_offset,
1187 int column_offset, bool is_embedder_debug_script, 1187 int column_offset, ScriptOriginOptions resource_options,
1188 bool is_shared_cross_origin, Handle<Object> source_map_url, 1188 Handle<Object> source_map_url, Handle<Context> context,
1189 Handle<Context> context, v8::Extension* extension, ScriptData** cached_data, 1189 v8::Extension* extension, ScriptData** cached_data,
1190 ScriptCompiler::CompileOptions compile_options, NativesFlag natives, 1190 ScriptCompiler::CompileOptions compile_options, NativesFlag natives,
1191 bool is_module) { 1191 bool is_module) {
1192 Isolate* isolate = source->GetIsolate(); 1192 Isolate* isolate = source->GetIsolate();
1193 if (compile_options == ScriptCompiler::kNoCompileOptions) { 1193 if (compile_options == ScriptCompiler::kNoCompileOptions) {
1194 cached_data = NULL; 1194 cached_data = NULL;
1195 } else if (compile_options == ScriptCompiler::kProduceParserCache || 1195 } else if (compile_options == ScriptCompiler::kProduceParserCache ||
1196 compile_options == ScriptCompiler::kProduceCodeCache) { 1196 compile_options == ScriptCompiler::kProduceCodeCache) {
1197 DCHECK(cached_data && !*cached_data); 1197 DCHECK(cached_data && !*cached_data);
1198 DCHECK(extension == NULL); 1198 DCHECK(extension == NULL);
1199 DCHECK(!isolate->debug()->is_loaded()); 1199 DCHECK(!isolate->debug()->is_loaded());
(...skipping 14 matching lines...) Expand all
1214 construct_language_mode(FLAG_use_strict, use_strong); 1214 construct_language_mode(FLAG_use_strict, use_strong);
1215 1215
1216 CompilationCache* compilation_cache = isolate->compilation_cache(); 1216 CompilationCache* compilation_cache = isolate->compilation_cache();
1217 1217
1218 // Do a lookup in the compilation cache but not for extensions. 1218 // Do a lookup in the compilation cache but not for extensions.
1219 MaybeHandle<SharedFunctionInfo> maybe_result; 1219 MaybeHandle<SharedFunctionInfo> maybe_result;
1220 Handle<SharedFunctionInfo> result; 1220 Handle<SharedFunctionInfo> result;
1221 if (extension == NULL) { 1221 if (extension == NULL) {
1222 // First check per-isolate compilation cache. 1222 // First check per-isolate compilation cache.
1223 maybe_result = compilation_cache->LookupScript( 1223 maybe_result = compilation_cache->LookupScript(
1224 source, script_name, line_offset, column_offset, 1224 source, script_name, line_offset, column_offset, resource_options,
1225 is_embedder_debug_script, is_shared_cross_origin, context, 1225 context, language_mode);
1226 language_mode);
1227 if (maybe_result.is_null() && FLAG_serialize_toplevel && 1226 if (maybe_result.is_null() && FLAG_serialize_toplevel &&
1228 compile_options == ScriptCompiler::kConsumeCodeCache && 1227 compile_options == ScriptCompiler::kConsumeCodeCache &&
1229 !isolate->debug()->is_loaded()) { 1228 !isolate->debug()->is_loaded()) {
1230 // Then check cached code provided by embedder. 1229 // Then check cached code provided by embedder.
1231 HistogramTimerScope timer(isolate->counters()->compile_deserialize()); 1230 HistogramTimerScope timer(isolate->counters()->compile_deserialize());
1232 Handle<SharedFunctionInfo> result; 1231 Handle<SharedFunctionInfo> result;
1233 if (CodeSerializer::Deserialize(isolate, *cached_data, source) 1232 if (CodeSerializer::Deserialize(isolate, *cached_data, source)
1234 .ToHandle(&result)) { 1233 .ToHandle(&result)) {
1235 // Promote to per-isolate compilation cache. 1234 // Promote to per-isolate compilation cache.
1236 DCHECK(!result->dont_cache()); 1235 DCHECK(!result->dont_cache());
(...skipping 16 matching lines...) Expand all
1253 // Create a script object describing the script to be compiled. 1252 // Create a script object describing the script to be compiled.
1254 Handle<Script> script = isolate->factory()->NewScript(source); 1253 Handle<Script> script = isolate->factory()->NewScript(source);
1255 if (natives == NATIVES_CODE) { 1254 if (natives == NATIVES_CODE) {
1256 script->set_type(Smi::FromInt(Script::TYPE_NATIVE)); 1255 script->set_type(Smi::FromInt(Script::TYPE_NATIVE));
1257 } 1256 }
1258 if (!script_name.is_null()) { 1257 if (!script_name.is_null()) {
1259 script->set_name(*script_name); 1258 script->set_name(*script_name);
1260 script->set_line_offset(Smi::FromInt(line_offset)); 1259 script->set_line_offset(Smi::FromInt(line_offset));
1261 script->set_column_offset(Smi::FromInt(column_offset)); 1260 script->set_column_offset(Smi::FromInt(column_offset));
1262 } 1261 }
1263 script->set_is_shared_cross_origin(is_shared_cross_origin); 1262 script->set_origin_options(resource_options);
1264 script->set_is_embedder_debug_script(is_embedder_debug_script);
1265 if (!source_map_url.is_null()) { 1263 if (!source_map_url.is_null()) {
1266 script->set_source_mapping_url(*source_map_url); 1264 script->set_source_mapping_url(*source_map_url);
1267 } 1265 }
1268 1266
1269 // Compile the function and add it to the cache. 1267 // Compile the function and add it to the cache.
1270 Zone zone; 1268 Zone zone;
1271 ParseInfo parse_info(&zone, script); 1269 ParseInfo parse_info(&zone, script);
1272 CompilationInfo info(&parse_info); 1270 CompilationInfo info(&parse_info);
1273 if (FLAG_harmony_modules && is_module) { 1271 if (FLAG_harmony_modules && is_module) {
1274 parse_info.set_module(); 1272 parse_info.set_module();
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
1565 } 1563 }
1566 1564
1567 1565
1568 #if DEBUG 1566 #if DEBUG
1569 void CompilationInfo::PrintAstForTesting() { 1567 void CompilationInfo::PrintAstForTesting() {
1570 PrintF("--- Source from AST ---\n%s\n", 1568 PrintF("--- Source from AST ---\n%s\n",
1571 PrettyPrinter(isolate(), zone()).PrintProgram(function())); 1569 PrettyPrinter(isolate(), zone()).PrintProgram(function()));
1572 } 1570 }
1573 #endif 1571 #endif
1574 } } // namespace v8::internal 1572 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/compiler.h ('k') | src/debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698