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

Side by Side Diff: src/compiler.cc

Issue 879553002: [V8] Added Script::is_debugger_script flag for embedders (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 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/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/compiler.h" 7 #include "src/compiler.h"
8 8
9 #include "src/ast-numbering.h" 9 #include "src/ast-numbering.h"
10 #include "src/ast-this-access-visitor.h" 10 #include "src/ast-this-access-visitor.h"
(...skipping 1246 matching lines...) Expand 10 before | Expand all | Expand 10 after
1257 shared_info->ResetForNewContext(isolate->heap()->global_ic_age()); 1257 shared_info->ResetForNewContext(isolate->heap()->global_ic_age());
1258 } 1258 }
1259 1259
1260 return isolate->factory()->NewFunctionFromSharedFunctionInfo( 1260 return isolate->factory()->NewFunctionFromSharedFunctionInfo(
1261 shared_info, context, NOT_TENURED); 1261 shared_info, context, NOT_TENURED);
1262 } 1262 }
1263 1263
1264 1264
1265 Handle<SharedFunctionInfo> Compiler::CompileScript( 1265 Handle<SharedFunctionInfo> Compiler::CompileScript(
1266 Handle<String> source, Handle<Object> script_name, int line_offset, 1266 Handle<String> source, Handle<Object> script_name, int line_offset,
1267 int column_offset, bool is_shared_cross_origin, Handle<Context> context, 1267 int column_offset, bool is_embedder_debug_script,
1268 bool is_shared_cross_origin, Handle<Context> context,
1268 v8::Extension* extension, ScriptData** cached_data, 1269 v8::Extension* extension, ScriptData** cached_data,
1269 ScriptCompiler::CompileOptions compile_options, NativesFlag natives) { 1270 ScriptCompiler::CompileOptions compile_options, NativesFlag natives) {
1270 Isolate* isolate = source->GetIsolate(); 1271 Isolate* isolate = source->GetIsolate();
1271 if (compile_options == ScriptCompiler::kNoCompileOptions) { 1272 if (compile_options == ScriptCompiler::kNoCompileOptions) {
1272 cached_data = NULL; 1273 cached_data = NULL;
1273 } else if (compile_options == ScriptCompiler::kProduceParserCache || 1274 } else if (compile_options == ScriptCompiler::kProduceParserCache ||
1274 compile_options == ScriptCompiler::kProduceCodeCache) { 1275 compile_options == ScriptCompiler::kProduceCodeCache) {
1275 DCHECK(cached_data && !*cached_data); 1276 DCHECK(cached_data && !*cached_data);
1276 DCHECK(extension == NULL); 1277 DCHECK(extension == NULL);
1277 DCHECK(!isolate->debug()->is_loaded()); 1278 DCHECK(!isolate->debug()->is_loaded());
1278 } else { 1279 } else {
1279 DCHECK(compile_options == ScriptCompiler::kConsumeParserCache || 1280 DCHECK(compile_options == ScriptCompiler::kConsumeParserCache ||
1280 compile_options == ScriptCompiler::kConsumeCodeCache); 1281 compile_options == ScriptCompiler::kConsumeCodeCache);
1281 DCHECK(cached_data && *cached_data); 1282 DCHECK(cached_data && *cached_data);
1282 DCHECK(extension == NULL); 1283 DCHECK(extension == NULL);
1283 } 1284 }
1284 int source_length = source->length(); 1285 int source_length = source->length();
1285 isolate->counters()->total_load_size()->Increment(source_length); 1286 isolate->counters()->total_load_size()->Increment(source_length);
1286 isolate->counters()->total_compile_size()->Increment(source_length); 1287 isolate->counters()->total_compile_size()->Increment(source_length);
1287 1288
1288 CompilationCache* compilation_cache = isolate->compilation_cache(); 1289 CompilationCache* compilation_cache = isolate->compilation_cache();
1289 1290
1290 // Do a lookup in the compilation cache but not for extensions. 1291 // Do a lookup in the compilation cache but not for extensions.
1291 MaybeHandle<SharedFunctionInfo> maybe_result; 1292 MaybeHandle<SharedFunctionInfo> maybe_result;
1292 Handle<SharedFunctionInfo> result; 1293 Handle<SharedFunctionInfo> result;
1293 if (extension == NULL) { 1294 if (extension == NULL) {
1294 maybe_result = compilation_cache->LookupScript( 1295 maybe_result = compilation_cache->LookupScript(
1295 source, script_name, line_offset, column_offset, is_shared_cross_origin, 1296 source, script_name, line_offset, column_offset,
1296 context); 1297 is_embedder_debug_script, is_shared_cross_origin, context);
1297 if (maybe_result.is_null() && FLAG_serialize_toplevel && 1298 if (maybe_result.is_null() && FLAG_serialize_toplevel &&
1298 compile_options == ScriptCompiler::kConsumeCodeCache && 1299 compile_options == ScriptCompiler::kConsumeCodeCache &&
1299 !isolate->debug()->is_loaded()) { 1300 !isolate->debug()->is_loaded()) {
1300 HistogramTimerScope timer(isolate->counters()->compile_deserialize()); 1301 HistogramTimerScope timer(isolate->counters()->compile_deserialize());
1301 Handle<SharedFunctionInfo> result; 1302 Handle<SharedFunctionInfo> result;
1302 if (CodeSerializer::Deserialize(isolate, *cached_data, source) 1303 if (CodeSerializer::Deserialize(isolate, *cached_data, source)
1303 .ToHandle(&result)) { 1304 .ToHandle(&result)) {
1304 return result; 1305 return result;
1305 } 1306 }
1306 // Deserializer failed. Fall through to compile. 1307 // Deserializer failed. Fall through to compile.
(...skipping 13 matching lines...) Expand all
1320 Handle<Script> script = isolate->factory()->NewScript(source); 1321 Handle<Script> script = isolate->factory()->NewScript(source);
1321 if (natives == NATIVES_CODE) { 1322 if (natives == NATIVES_CODE) {
1322 script->set_type(Smi::FromInt(Script::TYPE_NATIVE)); 1323 script->set_type(Smi::FromInt(Script::TYPE_NATIVE));
1323 } 1324 }
1324 if (!script_name.is_null()) { 1325 if (!script_name.is_null()) {
1325 script->set_name(*script_name); 1326 script->set_name(*script_name);
1326 script->set_line_offset(Smi::FromInt(line_offset)); 1327 script->set_line_offset(Smi::FromInt(line_offset));
1327 script->set_column_offset(Smi::FromInt(column_offset)); 1328 script->set_column_offset(Smi::FromInt(column_offset));
1328 } 1329 }
1329 script->set_is_shared_cross_origin(is_shared_cross_origin); 1330 script->set_is_shared_cross_origin(is_shared_cross_origin);
1331 script->set_is_embedder_debug_script(is_embedder_debug_script);
1330 1332
1331 // Compile the function and add it to the cache. 1333 // Compile the function and add it to the cache.
1332 CompilationInfoWithZone info(script); 1334 CompilationInfoWithZone info(script);
1333 info.MarkAsGlobal(); 1335 info.MarkAsGlobal();
1334 info.SetCachedData(cached_data, compile_options); 1336 info.SetCachedData(cached_data, compile_options);
1335 info.SetExtension(extension); 1337 info.SetExtension(extension);
1336 info.SetContext(context); 1338 info.SetContext(context);
1337 if (FLAG_serialize_toplevel && 1339 if (FLAG_serialize_toplevel &&
1338 compile_options == ScriptCompiler::kProduceCodeCache) { 1340 compile_options == ScriptCompiler::kProduceCodeCache) {
1339 info.PrepareForSerializing(); 1341 info.PrepareForSerializing();
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
1581 AllowHandleDereference allow_deref; 1583 AllowHandleDereference allow_deref;
1582 bool tracing_on = info()->IsStub() 1584 bool tracing_on = info()->IsStub()
1583 ? FLAG_trace_hydrogen_stubs 1585 ? FLAG_trace_hydrogen_stubs
1584 : (FLAG_trace_hydrogen && 1586 : (FLAG_trace_hydrogen &&
1585 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); 1587 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter));
1586 return (tracing_on && 1588 return (tracing_on &&
1587 base::OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); 1589 base::OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL);
1588 } 1590 }
1589 1591
1590 } } // namespace v8::internal 1592 } } // 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