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

Side by Side Diff: src/compiler.cc

Issue 2582583002: [wasm] simpler detection if we compiled asm-wasm (Closed)
Patch Set: using new iterator 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 | « no previous file | no next file » | 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 1348 matching lines...) Expand 10 before | Expand all | Expand 10 after
1359 if (callback == NULL) { 1359 if (callback == NULL) {
1360 // No callback set and code generation disallowed. 1360 // No callback set and code generation disallowed.
1361 return false; 1361 return false;
1362 } else { 1362 } else {
1363 // Callback set. Let it decide if code generation is allowed. 1363 // Callback set. Let it decide if code generation is allowed.
1364 VMState<EXTERNAL> state(isolate); 1364 VMState<EXTERNAL> state(isolate);
1365 return callback(v8::Utils::ToLocal(context)); 1365 return callback(v8::Utils::ToLocal(context));
1366 } 1366 }
1367 } 1367 }
1368 1368
1369 bool ContainsAsmModule(const Scope* scope, Zone* zone) { 1369 bool ContainsAsmModule(Handle<Script> script) {
1370 DCHECK_NOT_NULL(scope); 1370 DisallowHeapAllocation no_gc;
1371 DCHECK_NOT_NULL(zone); 1371 SharedFunctionInfo::ScriptIterator iter(script);
1372 ZoneQueue<const Scope*> worklist(zone); 1372 while (SharedFunctionInfo* info = iter.Next()) {
1373 // We assume scopes form a tree, so no need to check for cycles 1373 if (info->HasAsmWasmData()) return true;
1374 worklist.push(scope);
1375 while (!worklist.empty()) {
1376 const Scope* s = worklist.front();
1377 worklist.pop();
1378 if (s->IsAsmModule()) {
1379 return true;
1380 }
1381 for (const Scope* child = s->inner_scope(); child != nullptr;
1382 child = child->sibling()) {
1383 worklist.push(child);
1384 }
1385 } 1374 }
1386 return false; 1375 return false;
1387 } 1376 }
1388 1377
1389 } // namespace 1378 } // namespace
1390 1379
1391 MaybeHandle<JSFunction> Compiler::GetFunctionFromString( 1380 MaybeHandle<JSFunction> Compiler::GetFunctionFromString(
1392 Handle<Context> context, Handle<String> source, 1381 Handle<Context> context, Handle<String> source,
1393 ParseRestriction restriction) { 1382 ParseRestriction restriction) {
1394 Isolate* const isolate = context->GetIsolate(); 1383 Isolate* const isolate = context->GetIsolate();
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
1521 info.PrepareForSerializing(); 1510 info.PrepareForSerializing();
1522 } 1511 }
1523 1512
1524 parse_info.set_language_mode( 1513 parse_info.set_language_mode(
1525 static_cast<LanguageMode>(parse_info.language_mode() | language_mode)); 1514 static_cast<LanguageMode>(parse_info.language_mode() | language_mode));
1526 result = CompileToplevel(&info); 1515 result = CompileToplevel(&info);
1527 if (extension == NULL && !result.is_null()) { 1516 if (extension == NULL && !result.is_null()) {
1528 compilation_cache->PutScript(source, context, language_mode, result); 1517 compilation_cache->PutScript(source, context, language_mode, result);
1529 if (FLAG_serialize_toplevel && 1518 if (FLAG_serialize_toplevel &&
1530 compile_options == ScriptCompiler::kProduceCodeCache && 1519 compile_options == ScriptCompiler::kProduceCodeCache &&
1531 !ContainsAsmModule(info.scope(), &zone)) { 1520 !ContainsAsmModule(script)) {
1532 HistogramTimerScope histogram_timer( 1521 HistogramTimerScope histogram_timer(
1533 isolate->counters()->compile_serialize()); 1522 isolate->counters()->compile_serialize());
1534 RuntimeCallTimerScope runtimeTimer(isolate, 1523 RuntimeCallTimerScope runtimeTimer(isolate,
1535 &RuntimeCallStats::CompileSerialize); 1524 &RuntimeCallStats::CompileSerialize);
1536 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), 1525 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"),
1537 "V8.CompileSerialize"); 1526 "V8.CompileSerialize");
1538 *cached_data = CodeSerializer::Serialize(isolate, result, source); 1527 *cached_data = CodeSerializer::Serialize(isolate, result, source);
1539 if (FLAG_profile_deserialization) { 1528 if (FLAG_profile_deserialization) {
1540 PrintF("[Compiling and serializing took %0.3f ms]\n", 1529 PrintF("[Compiling and serializing took %0.3f ms]\n",
1541 timer.Elapsed().InMillisecondsF()); 1530 timer.Elapsed().InMillisecondsF());
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
1754 DCHECK(shared->is_compiled()); 1743 DCHECK(shared->is_compiled());
1755 function->set_literals(cached.literals); 1744 function->set_literals(cached.literals);
1756 } else if (shared->is_compiled()) { 1745 } else if (shared->is_compiled()) {
1757 // TODO(mvstanton): pass pretenure flag to EnsureLiterals. 1746 // TODO(mvstanton): pass pretenure flag to EnsureLiterals.
1758 JSFunction::EnsureLiterals(function); 1747 JSFunction::EnsureLiterals(function);
1759 } 1748 }
1760 } 1749 }
1761 1750
1762 } // namespace internal 1751 } // namespace internal
1763 } // namespace v8 1752 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698