| 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 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "src/asmjs/asm-js.h" | 10 #include "src/asmjs/asm-js.h" |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 } | 245 } |
| 246 code->set_can_have_weak_objects(true); | 246 code->set_can_have_weak_objects(true); |
| 247 } | 247 } |
| 248 | 248 |
| 249 // ---------------------------------------------------------------------------- | 249 // ---------------------------------------------------------------------------- |
| 250 // Local helper methods that make up the compilation pipeline. | 250 // Local helper methods that make up the compilation pipeline. |
| 251 | 251 |
| 252 namespace { | 252 namespace { |
| 253 | 253 |
| 254 bool Parse(ParseInfo* info) { | 254 bool Parse(ParseInfo* info) { |
| 255 // Create a canonical handle scope for compiling Ignition bytecode. This is | 255 // Create a canonical handle scope if compiling ignition bytecode. This is |
| 256 // required by the constant array builder to de-duplicate objects without | 256 // required by the constant array builder to de-duplicate objects without |
| 257 // dereferencing handles. | 257 // dereferencing handles. |
| 258 CanonicalHandleScope canonical(info->isolate()); | 258 std::unique_ptr<CanonicalHandleScope> canonical; |
| 259 if (FLAG_ignition) canonical.reset(new CanonicalHandleScope(info->isolate())); |
| 259 | 260 |
| 260 return Parser::ParseStatic(info); | 261 return Parser::ParseStatic(info); |
| 261 } | 262 } |
| 262 | 263 |
| 263 void RecordFunctionCompilation(CodeEventListener::LogEventsAndTags tag, | 264 void RecordFunctionCompilation(CodeEventListener::LogEventsAndTags tag, |
| 264 CompilationInfo* info) { | 265 CompilationInfo* info) { |
| 265 // Log the code generation. If source information is available include | 266 // Log the code generation. If source information is available include |
| 266 // script name and line number. Check explicitly whether logging is | 267 // script name and line number. Check explicitly whether logging is |
| 267 // enabled as finding the line number is not free. | 268 // enabled as finding the line number is not free. |
| 268 if (info->isolate()->logger()->is_logging_code_events() || | 269 if (info->isolate()->logger()->is_logging_code_events() || |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 // Cache optimized context-specific code. | 485 // Cache optimized context-specific code. |
| 485 Handle<JSFunction> function = info->closure(); | 486 Handle<JSFunction> function = info->closure(); |
| 486 Handle<SharedFunctionInfo> shared(function->shared()); | 487 Handle<SharedFunctionInfo> shared(function->shared()); |
| 487 Handle<LiteralsArray> literals(function->literals()); | 488 Handle<LiteralsArray> literals(function->literals()); |
| 488 Handle<Context> native_context(function->context()->native_context()); | 489 Handle<Context> native_context(function->context()->native_context()); |
| 489 SharedFunctionInfo::AddToOptimizedCodeMap(shared, native_context, code, | 490 SharedFunctionInfo::AddToOptimizedCodeMap(shared, native_context, code, |
| 490 literals, info->osr_ast_id()); | 491 literals, info->osr_ast_id()); |
| 491 } | 492 } |
| 492 | 493 |
| 493 bool Renumber(ParseInfo* parse_info) { | 494 bool Renumber(ParseInfo* parse_info) { |
| 494 // Create a canonical handle scope for compiling Ignition bytecode. This is | 495 // Create a canonical handle scope if compiling ignition bytecode. This is |
| 495 // required by the constant array builder to de-duplicate objects without | 496 // required by the constant array builder to de-duplicate objects without |
| 496 // dereferencing handles. | 497 // dereferencing handles. |
| 497 CanonicalHandleScope canonical(parse_info->isolate()); | 498 std::unique_ptr<CanonicalHandleScope> canonical; |
| 499 if (FLAG_ignition) { |
| 500 canonical.reset(new CanonicalHandleScope(parse_info->isolate())); |
| 501 } |
| 498 | 502 |
| 499 if (!AstNumbering::Renumber(parse_info->isolate(), parse_info->zone(), | 503 if (!AstNumbering::Renumber(parse_info->isolate(), parse_info->zone(), |
| 500 parse_info->literal())) { | 504 parse_info->literal())) { |
| 501 return false; | 505 return false; |
| 502 } | 506 } |
| 503 Handle<SharedFunctionInfo> shared_info = parse_info->shared_info(); | 507 Handle<SharedFunctionInfo> shared_info = parse_info->shared_info(); |
| 504 if (!shared_info.is_null()) { | 508 if (!shared_info.is_null()) { |
| 505 FunctionLiteral* lit = parse_info->literal(); | 509 FunctionLiteral* lit = parse_info->literal(); |
| 506 shared_info->set_ast_node_count(lit->ast_node_count()); | 510 shared_info->set_ast_node_count(lit->ast_node_count()); |
| 507 if (lit->dont_optimize_reason() != kNoReason) { | 511 if (lit->dont_optimize_reason() != kNoReason) { |
| (...skipping 1300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1808 DCHECK(shared->is_compiled()); | 1812 DCHECK(shared->is_compiled()); |
| 1809 function->set_literals(cached.literals); | 1813 function->set_literals(cached.literals); |
| 1810 } else if (shared->is_compiled()) { | 1814 } else if (shared->is_compiled()) { |
| 1811 // TODO(mvstanton): pass pretenure flag to EnsureLiterals. | 1815 // TODO(mvstanton): pass pretenure flag to EnsureLiterals. |
| 1812 JSFunction::EnsureLiterals(function); | 1816 JSFunction::EnsureLiterals(function); |
| 1813 } | 1817 } |
| 1814 } | 1818 } |
| 1815 | 1819 |
| 1816 } // namespace internal | 1820 } // namespace internal |
| 1817 } // namespace v8 | 1821 } // namespace v8 |
| OLD | NEW |