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

Side by Side Diff: src/compiler.cc

Issue 2573193002: [wasm] disable serialization for asm-wasm (Closed)
Patch Set: Comment 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 | test/mjsunit/regress/wasm/regression-643595.js » ('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 1327 matching lines...) Expand 10 before | Expand all | Expand 10 after
1338 if (callback == NULL) { 1338 if (callback == NULL) {
1339 // No callback set and code generation disallowed. 1339 // No callback set and code generation disallowed.
1340 return false; 1340 return false;
1341 } else { 1341 } else {
1342 // Callback set. Let it decide if code generation is allowed. 1342 // Callback set. Let it decide if code generation is allowed.
1343 VMState<EXTERNAL> state(isolate); 1343 VMState<EXTERNAL> state(isolate);
1344 return callback(v8::Utils::ToLocal(context)); 1344 return callback(v8::Utils::ToLocal(context));
1345 } 1345 }
1346 } 1346 }
1347 1347
1348 bool ContainsAsmModule(const Scope* scope, Zone* zone) {
1349 DCHECK_NOT_NULL(scope);
1350 DCHECK_NOT_NULL(zone);
1351 ZoneQueue<const Scope*> worklist(zone);
1352 // We assume scopes form a tree, so no need to check for cycles
Yang 2016/12/15 05:41:09 I think this can be done a lot easier. We have all
1353 worklist.push(scope);
1354 while (!worklist.empty()) {
1355 const Scope* s = worklist.front();
1356 worklist.pop();
1357 if (s->IsAsmModule()) {
1358 return true;
1359 }
1360 for (const Scope* child = s->inner_scope(); child != nullptr;
1361 child = child->sibling()) {
1362 worklist.push(child);
1363 }
1364 }
1365 return false;
1366 }
1367
1348 } // namespace 1368 } // namespace
1349 1369
1350 MaybeHandle<JSFunction> Compiler::GetFunctionFromString( 1370 MaybeHandle<JSFunction> Compiler::GetFunctionFromString(
1351 Handle<Context> context, Handle<String> source, 1371 Handle<Context> context, Handle<String> source,
1352 ParseRestriction restriction) { 1372 ParseRestriction restriction) {
1353 Isolate* const isolate = context->GetIsolate(); 1373 Isolate* const isolate = context->GetIsolate();
1354 Handle<Context> native_context(context->native_context(), isolate); 1374 Handle<Context> native_context(context->native_context(), isolate);
1355 1375
1356 // Check if native context allows code generation from 1376 // Check if native context allows code generation from
1357 // strings. Throw an exception if it doesn't. 1377 // strings. Throw an exception if it doesn't.
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
1479 compile_options == ScriptCompiler::kProduceCodeCache) { 1499 compile_options == ScriptCompiler::kProduceCodeCache) {
1480 info.PrepareForSerializing(); 1500 info.PrepareForSerializing();
1481 } 1501 }
1482 1502
1483 parse_info.set_language_mode( 1503 parse_info.set_language_mode(
1484 static_cast<LanguageMode>(parse_info.language_mode() | language_mode)); 1504 static_cast<LanguageMode>(parse_info.language_mode() | language_mode));
1485 result = CompileToplevel(&info); 1505 result = CompileToplevel(&info);
1486 if (extension == NULL && !result.is_null()) { 1506 if (extension == NULL && !result.is_null()) {
1487 compilation_cache->PutScript(source, context, language_mode, result); 1507 compilation_cache->PutScript(source, context, language_mode, result);
1488 if (FLAG_serialize_toplevel && 1508 if (FLAG_serialize_toplevel &&
1489 compile_options == ScriptCompiler::kProduceCodeCache) { 1509 compile_options == ScriptCompiler::kProduceCodeCache &&
1510 !ContainsAsmModule(info.scope(), &zone)) {
1490 HistogramTimerScope histogram_timer( 1511 HistogramTimerScope histogram_timer(
1491 isolate->counters()->compile_serialize()); 1512 isolate->counters()->compile_serialize());
1492 RuntimeCallTimerScope runtimeTimer(isolate, 1513 RuntimeCallTimerScope runtimeTimer(isolate,
1493 &RuntimeCallStats::CompileSerialize); 1514 &RuntimeCallStats::CompileSerialize);
1494 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), 1515 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"),
1495 "V8.CompileSerialize"); 1516 "V8.CompileSerialize");
1496 *cached_data = CodeSerializer::Serialize(isolate, result, source); 1517 *cached_data = CodeSerializer::Serialize(isolate, result, source);
1497 if (FLAG_profile_deserialization) { 1518 if (FLAG_profile_deserialization) {
1498 PrintF("[Compiling and serializing took %0.3f ms]\n", 1519 PrintF("[Compiling and serializing took %0.3f ms]\n",
1499 timer.Elapsed().InMillisecondsF()); 1520 timer.Elapsed().InMillisecondsF());
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
1725 DCHECK(shared->is_compiled()); 1746 DCHECK(shared->is_compiled());
1726 function->set_literals(cached.literals); 1747 function->set_literals(cached.literals);
1727 } else if (shared->is_compiled()) { 1748 } else if (shared->is_compiled()) {
1728 // TODO(mvstanton): pass pretenure flag to EnsureLiterals. 1749 // TODO(mvstanton): pass pretenure flag to EnsureLiterals.
1729 JSFunction::EnsureLiterals(function); 1750 JSFunction::EnsureLiterals(function);
1730 } 1751 }
1731 } 1752 }
1732 1753
1733 } // namespace internal 1754 } // namespace internal
1734 } // namespace v8 1755 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/regress/wasm/regression-643595.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698