Chromium Code Reviews| 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 13 matching lines...) Expand all Loading... | |
| 24 #include "src/isolate-inl.h" | 24 #include "src/isolate-inl.h" |
| 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/runtime-profiler.h" | 30 #include "src/runtime-profiler.h" |
| 31 #include "src/snapshot/code-serializer.h" | 31 #include "src/snapshot/code-serializer.h" |
| 32 #include "src/typing-asm.h" | 32 #include "src/typing-asm.h" |
| 33 #include "src/vm-state-inl.h" | 33 #include "src/vm-state-inl.h" |
| 34 #include "src/wasm/wasm-js.h" | |
| 34 | 35 |
| 35 namespace v8 { | 36 namespace v8 { |
| 36 namespace internal { | 37 namespace internal { |
| 37 | 38 |
| 38 | 39 |
| 39 #define PARSE_INFO_GETTER(type, name) \ | 40 #define PARSE_INFO_GETTER(type, name) \ |
| 40 type CompilationInfo::name() const { \ | 41 type CompilationInfo::name() const { \ |
| 41 CHECK(parse_info()); \ | 42 CHECK(parse_info()); \ |
| 42 return parse_info()->name(); \ | 43 return parse_info()->name(); \ |
| 43 } | 44 } |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 463 int CodeAndMetadataSize(CompilationInfo* info) { | 464 int CodeAndMetadataSize(CompilationInfo* info) { |
| 464 if (info->has_bytecode_array()) { | 465 if (info->has_bytecode_array()) { |
| 465 return info->bytecode_array()->SizeIncludingMetadata(); | 466 return info->bytecode_array()->SizeIncludingMetadata(); |
| 466 } | 467 } |
| 467 return info->code()->SizeIncludingMetadata(); | 468 return info->code()->SizeIncludingMetadata(); |
| 468 } | 469 } |
| 469 | 470 |
| 470 bool GenerateUnoptimizedCode(CompilationInfo* info) { | 471 bool GenerateUnoptimizedCode(CompilationInfo* info) { |
| 471 bool success; | 472 bool success; |
| 472 EnsureFeedbackMetadata(info); | 473 EnsureFeedbackMetadata(info); |
| 474 #if defined(V8_TARGET_ARCH_X64) | |
| 475 // TODO(bradnelson): Implement builtin and enable for other arches. | |
| 473 if (FLAG_validate_asm && info->scope()->asm_module()) { | 476 if (FLAG_validate_asm && info->scope()->asm_module()) { |
| 474 AsmTyper typer(info->isolate(), info->zone(), *(info->script()), | 477 Handle<FixedArray> wasm_data; |
| 475 info->literal()); | 478 if (WasmJs::ConvertAsmToWasm(info->parse_info(), true, &wasm_data)) { |
| 476 if (FLAG_enable_simd_asmjs) { | 479 info->shared_info()->set_asm_wasm_data(*wasm_data); |
| 477 typer.set_allow_simd(true); | 480 info->SetCode(info->isolate()->builtins()->InstantiateAsmJs()); |
| 478 } | 481 return true; |
| 479 if (!typer.Validate()) { | |
| 480 DCHECK(!info->isolate()->has_pending_exception()); | |
| 481 PrintF("Validation of asm.js module failed: %s", typer.error_message()); | |
| 482 } | 482 } |
| 483 } | 483 } |
| 484 #endif | |
| 484 if (FLAG_ignition && UseIgnition(info)) { | 485 if (FLAG_ignition && UseIgnition(info)) { |
| 485 success = interpreter::Interpreter::MakeBytecode(info); | 486 success = interpreter::Interpreter::MakeBytecode(info); |
| 486 } else { | 487 } else { |
| 487 success = FullCodeGenerator::MakeCode(info); | 488 success = FullCodeGenerator::MakeCode(info); |
| 488 } | 489 } |
| 489 if (success) { | 490 if (success) { |
| 490 Isolate* isolate = info->isolate(); | 491 Isolate* isolate = info->isolate(); |
| 491 Counters* counters = isolate->counters(); | 492 Counters* counters = isolate->counters(); |
| 492 // TODO(4280): Rename counters from "baseline" to "unoptimized" eventually. | 493 // TODO(4280): Rename counters from "baseline" to "unoptimized" eventually. |
| 493 counters->total_baseline_code_size()->Increment(CodeAndMetadataSize(info)); | 494 counters->total_baseline_code_size()->Increment(CodeAndMetadataSize(info)); |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 724 return true; | 725 return true; |
| 725 } | 726 } |
| 726 | 727 |
| 727 MaybeHandle<Code> GetOptimizedCode(Handle<JSFunction> function, | 728 MaybeHandle<Code> GetOptimizedCode(Handle<JSFunction> function, |
| 728 Compiler::ConcurrencyMode mode, | 729 Compiler::ConcurrencyMode mode, |
| 729 BailoutId osr_ast_id = BailoutId::None(), | 730 BailoutId osr_ast_id = BailoutId::None(), |
| 730 JavaScriptFrame* osr_frame = nullptr) { | 731 JavaScriptFrame* osr_frame = nullptr) { |
| 731 Isolate* isolate = function->GetIsolate(); | 732 Isolate* isolate = function->GetIsolate(); |
| 732 Handle<SharedFunctionInfo> shared(function->shared(), isolate); | 733 Handle<SharedFunctionInfo> shared(function->shared(), isolate); |
| 733 | 734 |
| 735 if (shared->HasAsmWasmData()) { | |
|
Michael Starzinger
2016/06/29 08:29:23
Can you elaborate on this guard. Is this needed fo
bradn
2016/06/30 07:59:36
Not needed. Leftover from prior ignorance on my pa
| |
| 736 return MaybeHandle<Code>(); | |
| 737 } | |
| 738 | |
| 734 Handle<Code> cached_code; | 739 Handle<Code> cached_code; |
| 735 if (GetCodeFromOptimizedCodeMap(function, osr_ast_id) | 740 if (GetCodeFromOptimizedCodeMap(function, osr_ast_id) |
| 736 .ToHandle(&cached_code)) { | 741 .ToHandle(&cached_code)) { |
| 737 if (FLAG_trace_opt) { | 742 if (FLAG_trace_opt) { |
| 738 PrintF("[found optimized code for "); | 743 PrintF("[found optimized code for "); |
| 739 function->ShortPrint(); | 744 function->ShortPrint(); |
| 740 if (!osr_ast_id.IsNone()) { | 745 if (!osr_ast_id.IsNone()) { |
| 741 PrintF(" at OSR AST id %d", osr_ast_id.ToInt()); | 746 PrintF(" at OSR AST id %d", osr_ast_id.ToInt()); |
| 742 } | 747 } |
| 743 PrintF("]\n"); | 748 PrintF("]\n"); |
| (...skipping 1076 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1820 DCHECK(shared->is_compiled()); | 1825 DCHECK(shared->is_compiled()); |
| 1821 function->set_literals(cached.literals); | 1826 function->set_literals(cached.literals); |
| 1822 } else if (shared->is_compiled()) { | 1827 } else if (shared->is_compiled()) { |
| 1823 // TODO(mvstanton): pass pretenure flag to EnsureLiterals. | 1828 // TODO(mvstanton): pass pretenure flag to EnsureLiterals. |
| 1824 JSFunction::EnsureLiterals(function); | 1829 JSFunction::EnsureLiterals(function); |
| 1825 } | 1830 } |
| 1826 } | 1831 } |
| 1827 | 1832 |
| 1828 } // namespace internal | 1833 } // namespace internal |
| 1829 } // namespace v8 | 1834 } // namespace v8 |
| OLD | NEW |