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

Side by Side Diff: src/compiler.cc

Issue 2398023002: [wasm] asm.js - Parse and convert asm.js to wasm a function at a time. (Closed)
Patch Set: fix Created 4 years 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/ast/scopes.cc ('k') | src/factory.h » ('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 #include <memory> 8 #include <memory>
9 9
10 #include "src/asmjs/asm-js.h" 10 #include "src/asmjs/asm-js.h"
(...skipping 930 matching lines...) Expand 10 before | Expand all | Expand 10 after
941 if (GetOptimizedCode(function, Compiler::NOT_CONCURRENT) 941 if (GetOptimizedCode(function, Compiler::NOT_CONCURRENT)
942 .ToHandle(&opt_code)) { 942 .ToHandle(&opt_code)) {
943 result = opt_code; 943 result = opt_code;
944 } 944 }
945 } 945 }
946 946
947 return result; 947 return result;
948 } 948 }
949 949
950 950
951 Handle<SharedFunctionInfo> NewSharedFunctionInfoForLiteral(
952 Isolate* isolate, FunctionLiteral* literal, Handle<Script> script) {
953 Handle<Code> code = isolate->builtins()->CompileLazy();
954 Handle<ScopeInfo> scope_info = handle(ScopeInfo::Empty(isolate));
955 Handle<SharedFunctionInfo> result = isolate->factory()->NewSharedFunctionInfo(
956 literal->name(), literal->materialized_literal_count(), literal->kind(),
957 code, scope_info);
958 SharedFunctionInfo::InitFromFunctionLiteral(result, literal);
959 SharedFunctionInfo::SetScript(result, script);
960 return result;
961 }
962
963 Handle<SharedFunctionInfo> CompileToplevel(CompilationInfo* info) { 951 Handle<SharedFunctionInfo> CompileToplevel(CompilationInfo* info) {
964 Isolate* isolate = info->isolate(); 952 Isolate* isolate = info->isolate();
965 TimerEventScope<TimerEventCompileCode> timer(isolate); 953 TimerEventScope<TimerEventCompileCode> timer(isolate);
966 RuntimeCallTimerScope runtimeTimer(isolate, &RuntimeCallStats::CompileCode); 954 RuntimeCallTimerScope runtimeTimer(isolate, &RuntimeCallStats::CompileCode);
967 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), "V8.CompileCode"); 955 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), "V8.CompileCode");
968 PostponeInterruptsScope postpone(isolate); 956 PostponeInterruptsScope postpone(isolate);
969 DCHECK(!isolate->native_context().is_null()); 957 DCHECK(!isolate->native_context().is_null());
970 ParseInfo* parse_info = info->parse_info(); 958 ParseInfo* parse_info = info->parse_info();
971 Handle<Script> script = parse_info->script(); 959 Handle<Script> script = parse_info->script();
972 960
(...skipping 18 matching lines...) Expand all
991 : &RuntimeCallStats::Compile); 979 : &RuntimeCallStats::Compile);
992 HistogramTimer* rate = parse_info->is_eval() 980 HistogramTimer* rate = parse_info->is_eval()
993 ? info->isolate()->counters()->compile_eval() 981 ? info->isolate()->counters()->compile_eval()
994 : info->isolate()->counters()->compile(); 982 : info->isolate()->counters()->compile();
995 HistogramTimerScope timer(rate); 983 HistogramTimerScope timer(rate);
996 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), 984 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"),
997 parse_info->is_eval() ? "V8.CompileEval" : "V8.Compile"); 985 parse_info->is_eval() ? "V8.CompileEval" : "V8.Compile");
998 986
999 // Allocate a shared function info object. 987 // Allocate a shared function info object.
1000 DCHECK_EQ(kNoSourcePosition, lit->function_token_position()); 988 DCHECK_EQ(kNoSourcePosition, lit->function_token_position());
1001 result = NewSharedFunctionInfoForLiteral(isolate, lit, script); 989 result = isolate->factory()->NewSharedFunctionInfoForLiteral(lit, script);
1002 result->set_is_toplevel(true); 990 result->set_is_toplevel(true);
1003 parse_info->set_shared_info(result); 991 parse_info->set_shared_info(result);
1004 parse_info->set_function_literal_id(result->function_literal_id()); 992 parse_info->set_function_literal_id(result->function_literal_id());
1005 993
1006 // Compile the code. 994 // Compile the code.
1007 if (!CompileUnoptimizedCode(info)) { 995 if (!CompileUnoptimizedCode(info)) {
1008 return Handle<SharedFunctionInfo>::null(); 996 return Handle<SharedFunctionInfo>::null();
1009 } 997 }
1010 998
1011 Handle<String> script_name = 999 Handle<String> script_name =
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after
1568 if (existing->HasBaselineCode() || existing->HasBytecodeArray()) { 1556 if (existing->HasBaselineCode() || existing->HasBytecodeArray()) {
1569 if (!outer_info->is_debug() || existing->HasDebugCode()) { 1557 if (!outer_info->is_debug() || existing->HasDebugCode()) {
1570 return existing; 1558 return existing;
1571 } 1559 }
1572 } 1560 }
1573 } 1561 }
1574 1562
1575 // Allocate a shared function info object. 1563 // Allocate a shared function info object.
1576 Handle<SharedFunctionInfo> result; 1564 Handle<SharedFunctionInfo> result;
1577 if (!maybe_existing.ToHandle(&result)) { 1565 if (!maybe_existing.ToHandle(&result)) {
1578 result = NewSharedFunctionInfoForLiteral(isolate, literal, script); 1566 result =
1567 isolate->factory()->NewSharedFunctionInfoForLiteral(literal, script);
1579 result->set_is_toplevel(false); 1568 result->set_is_toplevel(false);
1580 1569
1581 // If the outer function has been compiled before, we cannot be sure that 1570 // If the outer function has been compiled before, we cannot be sure that
1582 // shared function info for this function literal has been created for the 1571 // shared function info for this function literal has been created for the
1583 // first time. It may have already been compiled previously. 1572 // first time. It may have already been compiled previously.
1584 result->set_never_compiled(outer_info->shared_info()->never_compiled()); 1573 result->set_never_compiled(outer_info->shared_info()->never_compiled());
1585 } 1574 }
1586 1575
1587 Zone zone(isolate->allocator(), ZONE_NAME); 1576 Zone zone(isolate->allocator(), ZONE_NAME);
1588 ParseInfo parse_info(&zone, script); 1577 ParseInfo parse_info(&zone, script);
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
1728 DCHECK(shared->is_compiled()); 1717 DCHECK(shared->is_compiled());
1729 function->set_literals(cached.literals); 1718 function->set_literals(cached.literals);
1730 } else if (shared->is_compiled()) { 1719 } else if (shared->is_compiled()) {
1731 // TODO(mvstanton): pass pretenure flag to EnsureLiterals. 1720 // TODO(mvstanton): pass pretenure flag to EnsureLiterals.
1732 JSFunction::EnsureLiterals(function); 1721 JSFunction::EnsureLiterals(function);
1733 } 1722 }
1734 } 1723 }
1735 1724
1736 } // namespace internal 1725 } // namespace internal
1737 } // namespace v8 1726 } // namespace v8
OLDNEW
« no previous file with comments | « src/ast/scopes.cc ('k') | src/factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698