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

Side by Side Diff: src/compiler.cc

Issue 1888013002: Revert of Correctly annotate eval origin. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 8 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/compiler/ast-graph-builder.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/ast-numbering.h" 9 #include "src/ast/ast-numbering.h"
10 #include "src/ast/prettyprinter.h" 10 #include "src/ast/prettyprinter.h"
(...skipping 1250 matching lines...) Expand 10 before | Expand all | Expand 10 after
1261 if (!Parser::ParseStatic(info.parse_info())) return; 1261 if (!Parser::ParseStatic(info.parse_info())) return;
1262 1262
1263 LiveEditFunctionTracker tracker(info.isolate(), parse_info.literal()); 1263 LiveEditFunctionTracker tracker(info.isolate(), parse_info.literal());
1264 if (!CompileUnoptimizedCode(&info)) return; 1264 if (!CompileUnoptimizedCode(&info)) return;
1265 tracker.RecordRootFunctionInfo(info.code()); 1265 tracker.RecordRootFunctionInfo(info.code());
1266 } 1266 }
1267 1267
1268 MaybeHandle<JSFunction> Compiler::GetFunctionFromEval( 1268 MaybeHandle<JSFunction> Compiler::GetFunctionFromEval(
1269 Handle<String> source, Handle<SharedFunctionInfo> outer_info, 1269 Handle<String> source, Handle<SharedFunctionInfo> outer_info,
1270 Handle<Context> context, LanguageMode language_mode, 1270 Handle<Context> context, LanguageMode language_mode,
1271 ParseRestriction restriction, int eval_position, int line_offset, 1271 ParseRestriction restriction, int line_offset, int column_offset,
1272 int column_offset, Handle<Object> script_name, 1272 Handle<Object> script_name, ScriptOriginOptions options) {
1273 ScriptOriginOptions options) {
1274 Isolate* isolate = source->GetIsolate(); 1273 Isolate* isolate = source->GetIsolate();
1275 int source_length = source->length(); 1274 int source_length = source->length();
1276 isolate->counters()->total_eval_size()->Increment(source_length); 1275 isolate->counters()->total_eval_size()->Increment(source_length);
1277 isolate->counters()->total_compile_size()->Increment(source_length); 1276 isolate->counters()->total_compile_size()->Increment(source_length);
1278 1277
1279 CompilationCache* compilation_cache = isolate->compilation_cache(); 1278 CompilationCache* compilation_cache = isolate->compilation_cache();
1280 MaybeHandle<SharedFunctionInfo> maybe_shared_info = 1279 MaybeHandle<SharedFunctionInfo> maybe_shared_info =
1281 compilation_cache->LookupEval(source, outer_info, context, language_mode, 1280 compilation_cache->LookupEval(source, outer_info, context, language_mode,
1282 eval_position); 1281 line_offset);
1283 Handle<SharedFunctionInfo> shared_info; 1282 Handle<SharedFunctionInfo> shared_info;
1284 1283
1285 Handle<Script> script; 1284 Handle<Script> script;
1286 if (!maybe_shared_info.ToHandle(&shared_info)) { 1285 if (!maybe_shared_info.ToHandle(&shared_info)) {
1287 script = isolate->factory()->NewScript(source); 1286 script = isolate->factory()->NewScript(source);
1288 if (!script_name.is_null()) { 1287 if (!script_name.is_null()) {
1289 script->set_name(*script_name); 1288 script->set_name(*script_name);
1290 script->set_line_offset(line_offset); 1289 script->set_line_offset(line_offset);
1291 script->set_column_offset(column_offset); 1290 script->set_column_offset(column_offset);
1292 } 1291 }
1293 script->set_origin_options(options); 1292 script->set_origin_options(options);
1294 script->set_compilation_type(Script::COMPILATION_TYPE_EVAL);
1295 script->set_eval_from_shared(*outer_info);
1296 script->set_eval_from_position(eval_position);
1297
1298 Zone zone(isolate->allocator()); 1293 Zone zone(isolate->allocator());
1299 ParseInfo parse_info(&zone, script); 1294 ParseInfo parse_info(&zone, script);
1300 CompilationInfo info(&parse_info, Handle<JSFunction>::null()); 1295 CompilationInfo info(&parse_info, Handle<JSFunction>::null());
1301 parse_info.set_eval(); 1296 parse_info.set_eval();
1302 if (context->IsNativeContext()) parse_info.set_global(); 1297 if (context->IsNativeContext()) parse_info.set_global();
1303 parse_info.set_language_mode(language_mode); 1298 parse_info.set_language_mode(language_mode);
1304 parse_info.set_parse_restriction(restriction); 1299 parse_info.set_parse_restriction(restriction);
1305 parse_info.set_context(context); 1300 parse_info.set_context(context);
1306 1301
1302 Debug::RecordEvalCaller(script);
1303
1307 shared_info = CompileToplevel(&info); 1304 shared_info = CompileToplevel(&info);
1308 1305
1309 if (shared_info.is_null()) { 1306 if (shared_info.is_null()) {
1310 return MaybeHandle<JSFunction>(); 1307 return MaybeHandle<JSFunction>();
1311 } else { 1308 } else {
1312 // Explicitly disable optimization for eval code. We're not yet prepared 1309 // Explicitly disable optimization for eval code. We're not yet prepared
1313 // to handle eval-code in the optimizing compiler. 1310 // to handle eval-code in the optimizing compiler.
1314 if (restriction != ONLY_SINGLE_FUNCTION_LITERAL) { 1311 if (restriction != ONLY_SINGLE_FUNCTION_LITERAL) {
1315 shared_info->DisableOptimization(kEval); 1312 shared_info->DisableOptimization(kEval);
1316 } 1313 }
1317 1314
1318 // If caller is strict mode, the result must be in strict mode as well. 1315 // If caller is strict mode, the result must be in strict mode as well.
1319 DCHECK(is_sloppy(language_mode) || 1316 DCHECK(is_sloppy(language_mode) ||
1320 is_strict(shared_info->language_mode())); 1317 is_strict(shared_info->language_mode()));
1321 compilation_cache->PutEval(source, outer_info, context, shared_info, 1318 compilation_cache->PutEval(source, outer_info, context, shared_info,
1322 eval_position); 1319 line_offset);
1323 } 1320 }
1324 } 1321 }
1325 1322
1326 Handle<JSFunction> result = 1323 Handle<JSFunction> result =
1327 isolate->factory()->NewFunctionFromSharedFunctionInfo( 1324 isolate->factory()->NewFunctionFromSharedFunctionInfo(
1328 shared_info, context, NOT_TENURED); 1325 shared_info, context, NOT_TENURED);
1329 1326
1330 // OnAfterCompile has to be called after we create the JSFunction, which we 1327 // OnAfterCompile has to be called after we create the JSFunction, which we
1331 // may require to recompile the eval for debugging, if we find a function 1328 // may require to recompile the eval for debugging, if we find a function
1332 // that contains break points in the eval script. 1329 // that contains break points in the eval script.
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
1717 MaybeHandle<Code> code; 1714 MaybeHandle<Code> code;
1718 if (cached.code != nullptr) code = handle(cached.code); 1715 if (cached.code != nullptr) code = handle(cached.code);
1719 Handle<Context> native_context(function->context()->native_context()); 1716 Handle<Context> native_context(function->context()->native_context());
1720 SharedFunctionInfo::AddToOptimizedCodeMap(shared, native_context, code, 1717 SharedFunctionInfo::AddToOptimizedCodeMap(shared, native_context, code,
1721 literals, BailoutId::None()); 1718 literals, BailoutId::None());
1722 } 1719 }
1723 } 1720 }
1724 1721
1725 } // namespace internal 1722 } // namespace internal
1726 } // namespace v8 1723 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler.h ('k') | src/compiler/ast-graph-builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698