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

Side by Side Diff: src/compiler.cc

Issue 1858773004: 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 1491 matching lines...) Expand 10 before | Expand all | Expand 10 after
1502 Handle<ScopeInfo> scope_info = 1502 Handle<ScopeInfo> scope_info =
1503 ScopeInfo::Create(info.isolate(), info.zone(), info.scope()); 1503 ScopeInfo::Create(info.isolate(), info.zone(), info.scope());
1504 info.shared_info()->set_scope_info(*scope_info); 1504 info.shared_info()->set_scope_info(*scope_info);
1505 } 1505 }
1506 tracker.RecordRootFunctionInfo(info.code()); 1506 tracker.RecordRootFunctionInfo(info.code());
1507 } 1507 }
1508 1508
1509 MaybeHandle<JSFunction> Compiler::GetFunctionFromEval( 1509 MaybeHandle<JSFunction> Compiler::GetFunctionFromEval(
1510 Handle<String> source, Handle<SharedFunctionInfo> outer_info, 1510 Handle<String> source, Handle<SharedFunctionInfo> outer_info,
1511 Handle<Context> context, LanguageMode language_mode, 1511 Handle<Context> context, LanguageMode language_mode,
1512 ParseRestriction restriction, int eval_position, int line_offset, 1512 ParseRestriction restriction, int line_offset, int column_offset,
1513 int column_offset, Handle<Object> script_name, 1513 Handle<Object> script_name, ScriptOriginOptions options) {
1514 ScriptOriginOptions options) {
1515 Isolate* isolate = source->GetIsolate(); 1514 Isolate* isolate = source->GetIsolate();
1516 int source_length = source->length(); 1515 int source_length = source->length();
1517 isolate->counters()->total_eval_size()->Increment(source_length); 1516 isolate->counters()->total_eval_size()->Increment(source_length);
1518 isolate->counters()->total_compile_size()->Increment(source_length); 1517 isolate->counters()->total_compile_size()->Increment(source_length);
1519 1518
1520 CompilationCache* compilation_cache = isolate->compilation_cache(); 1519 CompilationCache* compilation_cache = isolate->compilation_cache();
1521 MaybeHandle<SharedFunctionInfo> maybe_shared_info = 1520 MaybeHandle<SharedFunctionInfo> maybe_shared_info =
1522 compilation_cache->LookupEval(source, outer_info, context, language_mode, 1521 compilation_cache->LookupEval(source, outer_info, context, language_mode,
1523 eval_position); 1522 line_offset);
1524 Handle<SharedFunctionInfo> shared_info; 1523 Handle<SharedFunctionInfo> shared_info;
1525 1524
1526 Handle<Script> script; 1525 Handle<Script> script;
1527 if (!maybe_shared_info.ToHandle(&shared_info)) { 1526 if (!maybe_shared_info.ToHandle(&shared_info)) {
1528 script = isolate->factory()->NewScript(source); 1527 script = isolate->factory()->NewScript(source);
1529 if (!script_name.is_null()) { 1528 if (!script_name.is_null()) {
1530 script->set_name(*script_name); 1529 script->set_name(*script_name);
1531 script->set_line_offset(line_offset); 1530 script->set_line_offset(line_offset);
1532 script->set_column_offset(column_offset); 1531 script->set_column_offset(column_offset);
1533 } 1532 }
1534 script->set_origin_options(options); 1533 script->set_origin_options(options);
1535 script->set_compilation_type(Script::COMPILATION_TYPE_EVAL);
1536 script->set_eval_from_shared(*outer_info);
1537 script->set_eval_from_position(eval_position);
1538
1539 Zone zone(isolate->allocator()); 1534 Zone zone(isolate->allocator());
1540 ParseInfo parse_info(&zone, script); 1535 ParseInfo parse_info(&zone, script);
1541 CompilationInfo info(&parse_info); 1536 CompilationInfo info(&parse_info);
1542 parse_info.set_eval(); 1537 parse_info.set_eval();
1543 if (context->IsNativeContext()) parse_info.set_global(); 1538 if (context->IsNativeContext()) parse_info.set_global();
1544 parse_info.set_language_mode(language_mode); 1539 parse_info.set_language_mode(language_mode);
1545 parse_info.set_parse_restriction(restriction); 1540 parse_info.set_parse_restriction(restriction);
1546 parse_info.set_context(context); 1541 parse_info.set_context(context);
1547 1542
1543 Debug::RecordEvalCaller(script);
1544
1548 shared_info = CompileToplevel(&info); 1545 shared_info = CompileToplevel(&info);
1549 1546
1550 if (shared_info.is_null()) { 1547 if (shared_info.is_null()) {
1551 return MaybeHandle<JSFunction>(); 1548 return MaybeHandle<JSFunction>();
1552 } else { 1549 } else {
1553 // Explicitly disable optimization for eval code. We're not yet prepared 1550 // Explicitly disable optimization for eval code. We're not yet prepared
1554 // to handle eval-code in the optimizing compiler. 1551 // to handle eval-code in the optimizing compiler.
1555 if (restriction != ONLY_SINGLE_FUNCTION_LITERAL) { 1552 if (restriction != ONLY_SINGLE_FUNCTION_LITERAL) {
1556 shared_info->DisableOptimization(kEval); 1553 shared_info->DisableOptimization(kEval);
1557 } 1554 }
1558 1555
1559 // If caller is strict mode, the result must be in strict mode as well. 1556 // If caller is strict mode, the result must be in strict mode as well.
1560 DCHECK(is_sloppy(language_mode) || 1557 DCHECK(is_sloppy(language_mode) ||
1561 is_strict(shared_info->language_mode())); 1558 is_strict(shared_info->language_mode()));
1562 compilation_cache->PutEval(source, outer_info, context, shared_info, 1559 compilation_cache->PutEval(source, outer_info, context, shared_info,
1563 eval_position); 1560 line_offset);
1564 } 1561 }
1565 } 1562 }
1566 1563
1567 Handle<JSFunction> result = 1564 Handle<JSFunction> result =
1568 isolate->factory()->NewFunctionFromSharedFunctionInfo( 1565 isolate->factory()->NewFunctionFromSharedFunctionInfo(
1569 shared_info, context, NOT_TENURED); 1566 shared_info, context, NOT_TENURED);
1570 1567
1571 // OnAfterCompile has to be called after we create the JSFunction, which we 1568 // OnAfterCompile has to be called after we create the JSFunction, which we
1572 // may require to recompile the eval for debugging, if we find a function 1569 // may require to recompile the eval for debugging, if we find a function
1573 // that contains break points in the eval script. 1570 // that contains break points in the eval script.
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
1960 MaybeHandle<Code> code; 1957 MaybeHandle<Code> code;
1961 if (cached.code != nullptr) code = handle(cached.code); 1958 if (cached.code != nullptr) code = handle(cached.code);
1962 Handle<Context> native_context(function->context()->native_context()); 1959 Handle<Context> native_context(function->context()->native_context());
1963 SharedFunctionInfo::AddToOptimizedCodeMap(shared, native_context, code, 1960 SharedFunctionInfo::AddToOptimizedCodeMap(shared, native_context, code,
1964 literals, BailoutId::None()); 1961 literals, BailoutId::None());
1965 } 1962 }
1966 } 1963 }
1967 1964
1968 } // namespace internal 1965 } // namespace internal
1969 } // namespace v8 1966 } // 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