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

Side by Side Diff: src/compiler.cc

Issue 952893006: Take the ScriptOrigin into account for CompileFunctionInContext (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 9 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') | test/cctest/test-compiler.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/bootstrapper.h" 10 #include "src/bootstrapper.h"
(...skipping 1188 matching lines...) Expand 10 before | Expand all | Expand 10 after
1199 1199
1200 isolate->debug()->OnAfterCompile(script); 1200 isolate->debug()->OnAfterCompile(script);
1201 1201
1202 return result; 1202 return result;
1203 } 1203 }
1204 1204
1205 1205
1206 MaybeHandle<JSFunction> Compiler::GetFunctionFromEval( 1206 MaybeHandle<JSFunction> Compiler::GetFunctionFromEval(
1207 Handle<String> source, Handle<SharedFunctionInfo> outer_info, 1207 Handle<String> source, Handle<SharedFunctionInfo> outer_info,
1208 Handle<Context> context, LanguageMode language_mode, 1208 Handle<Context> context, LanguageMode language_mode,
1209 ParseRestriction restriction, int scope_position) { 1209 ParseRestriction restriction, int line_offset, int column_offset,
1210 Handle<Object> script_name, bool is_embedder_debug_script,
1211 bool is_shared_cross_origin) {
1210 Isolate* isolate = source->GetIsolate(); 1212 Isolate* isolate = source->GetIsolate();
1211 int source_length = source->length(); 1213 int source_length = source->length();
1212 isolate->counters()->total_eval_size()->Increment(source_length); 1214 isolate->counters()->total_eval_size()->Increment(source_length);
1213 isolate->counters()->total_compile_size()->Increment(source_length); 1215 isolate->counters()->total_compile_size()->Increment(source_length);
1214 1216
1215 CompilationCache* compilation_cache = isolate->compilation_cache(); 1217 CompilationCache* compilation_cache = isolate->compilation_cache();
1216 MaybeHandle<SharedFunctionInfo> maybe_shared_info = 1218 MaybeHandle<SharedFunctionInfo> maybe_shared_info =
1217 compilation_cache->LookupEval(source, outer_info, context, language_mode, 1219 compilation_cache->LookupEval(source, outer_info, context, language_mode,
1218 scope_position); 1220 line_offset);
1219 Handle<SharedFunctionInfo> shared_info; 1221 Handle<SharedFunctionInfo> shared_info;
1220 1222
1221 if (!maybe_shared_info.ToHandle(&shared_info)) { 1223 if (!maybe_shared_info.ToHandle(&shared_info)) {
1222 Handle<Script> script = isolate->factory()->NewScript(source); 1224 Handle<Script> script = isolate->factory()->NewScript(source);
1225 if (!script_name.is_null()) {
1226 script->set_name(*script_name);
1227 script->set_line_offset(Smi::FromInt(line_offset));
1228 script->set_column_offset(Smi::FromInt(column_offset));
1229 }
1230 script->set_is_shared_cross_origin(is_shared_cross_origin);
1231 script->set_is_embedder_debug_script(is_embedder_debug_script);
1223 CompilationInfoWithZone info(script); 1232 CompilationInfoWithZone info(script);
1224 info.MarkAsEval(); 1233 info.MarkAsEval();
1225 if (context->IsNativeContext()) info.MarkAsGlobal(); 1234 if (context->IsNativeContext()) info.MarkAsGlobal();
1226 info.SetLanguageMode(language_mode); 1235 info.SetLanguageMode(language_mode);
1227 info.SetParseRestriction(restriction); 1236 info.SetParseRestriction(restriction);
1228 info.SetContext(context); 1237 info.SetContext(context);
1229 1238
1230 Debug::RecordEvalCaller(script); 1239 Debug::RecordEvalCaller(script);
1231 1240
1232 shared_info = CompileToplevel(&info); 1241 shared_info = CompileToplevel(&info);
1233 1242
1234 if (shared_info.is_null()) { 1243 if (shared_info.is_null()) {
1235 return MaybeHandle<JSFunction>(); 1244 return MaybeHandle<JSFunction>();
1236 } else { 1245 } else {
1237 // Explicitly disable optimization for eval code. We're not yet prepared 1246 // Explicitly disable optimization for eval code. We're not yet prepared
1238 // to handle eval-code in the optimizing compiler. 1247 // to handle eval-code in the optimizing compiler.
1239 if (restriction != ONLY_SINGLE_FUNCTION_LITERAL) { 1248 if (restriction != ONLY_SINGLE_FUNCTION_LITERAL) {
1240 shared_info->DisableOptimization(kEval); 1249 shared_info->DisableOptimization(kEval);
1241 } 1250 }
1242 1251
1243 // If caller is strict mode, the result must be in strict mode as well. 1252 // If caller is strict mode, the result must be in strict mode as well.
1244 DCHECK(is_sloppy(language_mode) || 1253 DCHECK(is_sloppy(language_mode) ||
1245 is_strict(shared_info->language_mode())); 1254 is_strict(shared_info->language_mode()));
1246 if (!shared_info->dont_cache()) { 1255 if (!shared_info->dont_cache()) {
1247 compilation_cache->PutEval(source, outer_info, context, shared_info, 1256 compilation_cache->PutEval(source, outer_info, context, shared_info,
1248 scope_position); 1257 line_offset);
1249 } 1258 }
1250 } 1259 }
1251 } else if (shared_info->ic_age() != isolate->heap()->global_ic_age()) { 1260 } else if (shared_info->ic_age() != isolate->heap()->global_ic_age()) {
1252 shared_info->ResetForNewContext(isolate->heap()->global_ic_age()); 1261 shared_info->ResetForNewContext(isolate->heap()->global_ic_age());
1253 } 1262 }
1254 1263
1255 return isolate->factory()->NewFunctionFromSharedFunctionInfo( 1264 return isolate->factory()->NewFunctionFromSharedFunctionInfo(
1256 shared_info, context, NOT_TENURED); 1265 shared_info, context, NOT_TENURED);
1257 } 1266 }
1258 1267
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
1606 } 1615 }
1607 1616
1608 1617
1609 #if DEBUG 1618 #if DEBUG
1610 void CompilationInfo::PrintAstForTesting() { 1619 void CompilationInfo::PrintAstForTesting() {
1611 PrintF("--- Source from AST ---\n%s\n", 1620 PrintF("--- Source from AST ---\n%s\n",
1612 PrettyPrinter(isolate(), zone()).PrintProgram(function())); 1621 PrettyPrinter(isolate(), zone()).PrintProgram(function()));
1613 } 1622 }
1614 #endif 1623 #endif
1615 } } // namespace v8::internal 1624 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/compiler.h ('k') | test/cctest/test-compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698