| OLD | NEW |
| 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 14 matching lines...) Expand all Loading... |
| 25 #include "src/log-inl.h" | 25 #include "src/log-inl.h" |
| 26 #include "src/messages.h" | 26 #include "src/messages.h" |
| 27 #include "src/parsing/parser.h" | 27 #include "src/parsing/parser.h" |
| 28 #include "src/parsing/rewriter.h" | 28 #include "src/parsing/rewriter.h" |
| 29 #include "src/parsing/scanner-character-streams.h" | 29 #include "src/parsing/scanner-character-streams.h" |
| 30 #include "src/profiler/cpu-profiler.h" | 30 #include "src/profiler/cpu-profiler.h" |
| 31 #include "src/runtime-profiler.h" | 31 #include "src/runtime-profiler.h" |
| 32 #include "src/snapshot/code-serializer.h" | 32 #include "src/snapshot/code-serializer.h" |
| 33 #include "src/typing-asm.h" | 33 #include "src/typing-asm.h" |
| 34 #include "src/vm-state-inl.h" | 34 #include "src/vm-state-inl.h" |
| 35 #include "src/wasm/wasm-js.h" |
| 35 | 36 |
| 36 namespace v8 { | 37 namespace v8 { |
| 37 namespace internal { | 38 namespace internal { |
| 38 | 39 |
| 39 | 40 |
| 40 #define PARSE_INFO_GETTER(type, name) \ | 41 #define PARSE_INFO_GETTER(type, name) \ |
| 41 type CompilationInfo::name() const { \ | 42 type CompilationInfo::name() const { \ |
| 42 CHECK(parse_info()); \ | 43 CHECK(parse_info()); \ |
| 43 return parse_info()->name(); \ | 44 return parse_info()->name(); \ |
| 44 } | 45 } |
| (...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 if (info->has_bytecode_array()) { | 466 if (info->has_bytecode_array()) { |
| 466 return info->bytecode_array()->SizeIncludingMetadata(); | 467 return info->bytecode_array()->SizeIncludingMetadata(); |
| 467 } | 468 } |
| 468 return info->code()->SizeIncludingMetadata(); | 469 return info->code()->SizeIncludingMetadata(); |
| 469 } | 470 } |
| 470 | 471 |
| 471 bool GenerateUnoptimizedCode(CompilationInfo* info) { | 472 bool GenerateUnoptimizedCode(CompilationInfo* info) { |
| 472 bool success; | 473 bool success; |
| 473 EnsureFeedbackMetadata(info); | 474 EnsureFeedbackMetadata(info); |
| 474 if (FLAG_validate_asm && info->scope()->asm_module()) { | 475 if (FLAG_validate_asm && info->scope()->asm_module()) { |
| 475 AsmTyper typer(info->isolate(), info->zone(), *(info->script()), | 476 Handle<FixedArray> wasm_data; |
| 476 info->literal()); | 477 if (WasmJs::ConvertAsmToWasm(info->parse_info(), &wasm_data)) { |
| 477 if (FLAG_enable_simd_asmjs) { | 478 info->shared_info()->set_asm_wasm_data(*wasm_data); |
| 478 typer.set_allow_simd(true); | 479 info->SetCode(info->isolate()->builtins()->CompileAsmJs()); |
| 479 } | 480 return true; |
| 480 if (!typer.Validate()) { | |
| 481 DCHECK(!info->isolate()->has_pending_exception()); | |
| 482 PrintF("Validation of asm.js module failed: %s", typer.error_message()); | |
| 483 } | 481 } |
| 484 } | 482 } |
| 485 if (FLAG_ignition && UseIgnition(info)) { | 483 if (FLAG_ignition && UseIgnition(info)) { |
| 486 success = interpreter::Interpreter::MakeBytecode(info); | 484 success = interpreter::Interpreter::MakeBytecode(info); |
| 487 } else { | 485 } else { |
| 488 success = FullCodeGenerator::MakeCode(info); | 486 success = FullCodeGenerator::MakeCode(info); |
| 489 } | 487 } |
| 490 if (success) { | 488 if (success) { |
| 491 Isolate* isolate = info->isolate(); | 489 Isolate* isolate = info->isolate(); |
| 492 Counters* counters = isolate->counters(); | 490 Counters* counters = isolate->counters(); |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 721 return true; | 719 return true; |
| 722 } | 720 } |
| 723 | 721 |
| 724 MaybeHandle<Code> GetOptimizedCode(Handle<JSFunction> function, | 722 MaybeHandle<Code> GetOptimizedCode(Handle<JSFunction> function, |
| 725 Compiler::ConcurrencyMode mode, | 723 Compiler::ConcurrencyMode mode, |
| 726 BailoutId osr_ast_id = BailoutId::None(), | 724 BailoutId osr_ast_id = BailoutId::None(), |
| 727 JavaScriptFrame* osr_frame = nullptr) { | 725 JavaScriptFrame* osr_frame = nullptr) { |
| 728 Isolate* isolate = function->GetIsolate(); | 726 Isolate* isolate = function->GetIsolate(); |
| 729 Handle<SharedFunctionInfo> shared(function->shared(), isolate); | 727 Handle<SharedFunctionInfo> shared(function->shared(), isolate); |
| 730 | 728 |
| 729 if (shared->HasAsmWasmData()) { |
| 730 return MaybeHandle<Code>(); |
| 731 } |
| 732 |
| 731 Handle<Code> cached_code; | 733 Handle<Code> cached_code; |
| 732 if (GetCodeFromOptimizedCodeMap(function, osr_ast_id) | 734 if (GetCodeFromOptimizedCodeMap(function, osr_ast_id) |
| 733 .ToHandle(&cached_code)) { | 735 .ToHandle(&cached_code)) { |
| 734 if (FLAG_trace_opt) { | 736 if (FLAG_trace_opt) { |
| 735 PrintF("[found optimized code for "); | 737 PrintF("[found optimized code for "); |
| 736 function->ShortPrint(); | 738 function->ShortPrint(); |
| 737 if (!osr_ast_id.IsNone()) { | 739 if (!osr_ast_id.IsNone()) { |
| 738 PrintF(" at OSR AST id %d", osr_ast_id.ToInt()); | 740 PrintF(" at OSR AST id %d", osr_ast_id.ToInt()); |
| 739 } | 741 } |
| 740 PrintF("]\n"); | 742 PrintF("]\n"); |
| (...skipping 1064 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1805 DCHECK(shared->is_compiled()); | 1807 DCHECK(shared->is_compiled()); |
| 1806 function->set_literals(cached.literals); | 1808 function->set_literals(cached.literals); |
| 1807 } else if (shared->is_compiled()) { | 1809 } else if (shared->is_compiled()) { |
| 1808 // TODO(mvstanton): pass pretenure flag to EnsureLiterals. | 1810 // TODO(mvstanton): pass pretenure flag to EnsureLiterals. |
| 1809 JSFunction::EnsureLiterals(function); | 1811 JSFunction::EnsureLiterals(function); |
| 1810 } | 1812 } |
| 1811 } | 1813 } |
| 1812 | 1814 |
| 1813 } // namespace internal | 1815 } // namespace internal |
| 1814 } // namespace v8 | 1816 } // namespace v8 |
| OLD | NEW |