| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 1561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1572 } | 1572 } |
| 1573 | 1573 |
| 1574 | 1574 |
| 1575 void FullCodeGenerator::VisitNativeFunctionLiteral( | 1575 void FullCodeGenerator::VisitNativeFunctionLiteral( |
| 1576 NativeFunctionLiteral* expr) { | 1576 NativeFunctionLiteral* expr) { |
| 1577 Comment cmnt(masm_, "[ NativeFunctionLiteral"); | 1577 Comment cmnt(masm_, "[ NativeFunctionLiteral"); |
| 1578 | 1578 |
| 1579 // Compute the function template for the native function. | 1579 // Compute the function template for the native function. |
| 1580 Handle<String> name = expr->name(); | 1580 Handle<String> name = expr->name(); |
| 1581 v8::Handle<v8::FunctionTemplate> fun_template = | 1581 v8::Handle<v8::FunctionTemplate> fun_template = |
| 1582 expr->extension()->GetNativeFunction(v8::Utils::ToLocal(name)); | 1582 expr->extension()->GetNativeFunctionTemplate( |
| 1583 reinterpret_cast<v8::Isolate*>(isolate()), v8::Utils::ToLocal(name)); |
| 1583 ASSERT(!fun_template.IsEmpty()); | 1584 ASSERT(!fun_template.IsEmpty()); |
| 1584 | 1585 |
| 1585 // Instantiate the function and create a shared function info from it. | 1586 // Instantiate the function and create a shared function info from it. |
| 1586 Handle<JSFunction> fun = Utils::OpenHandle(*fun_template->GetFunction()); | 1587 Handle<JSFunction> fun = Utils::OpenHandle(*fun_template->GetFunction()); |
| 1587 const int literals = fun->NumberOfLiterals(); | 1588 const int literals = fun->NumberOfLiterals(); |
| 1588 Handle<Code> code = Handle<Code>(fun->shared()->code()); | 1589 Handle<Code> code = Handle<Code>(fun->shared()->code()); |
| 1589 Handle<Code> construct_stub = Handle<Code>(fun->shared()->construct_stub()); | 1590 Handle<Code> construct_stub = Handle<Code>(fun->shared()->construct_stub()); |
| 1590 bool is_generator = false; | 1591 bool is_generator = false; |
| 1591 Handle<SharedFunctionInfo> shared = | 1592 Handle<SharedFunctionInfo> shared = |
| 1592 isolate()->factory()->NewSharedFunctionInfo(name, literals, is_generator, | 1593 isolate()->factory()->NewSharedFunctionInfo(name, literals, is_generator, |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1689 unoptimized->set_back_edges_patched_for_osr(false); | 1690 unoptimized->set_back_edges_patched_for_osr(false); |
| 1690 unoptimized->set_allow_osr_at_loop_nesting_level(0); | 1691 unoptimized->set_allow_osr_at_loop_nesting_level(0); |
| 1691 // Assert that none of the back edges are patched anymore. | 1692 // Assert that none of the back edges are patched anymore. |
| 1692 ASSERT(Verify(isolate, unoptimized, -1)); | 1693 ASSERT(Verify(isolate, unoptimized, -1)); |
| 1693 } | 1694 } |
| 1694 | 1695 |
| 1695 | 1696 |
| 1696 void BackEdgeTable::AddStackCheck(CompilationInfo* info) { | 1697 void BackEdgeTable::AddStackCheck(CompilationInfo* info) { |
| 1697 DisallowHeapAllocation no_gc; | 1698 DisallowHeapAllocation no_gc; |
| 1698 Isolate* isolate = info->isolate(); | 1699 Isolate* isolate = info->isolate(); |
| 1699 Code* code = info->shared_info()->code(); | 1700 Code* code = *info->osr_patched_code(); |
| 1700 Address pc = code->instruction_start() + info->osr_pc_offset(); | 1701 Address pc = code->instruction_start() + info->osr_pc_offset(); |
| 1701 ASSERT_EQ(ON_STACK_REPLACEMENT, GetBackEdgeState(isolate, code, pc)); | 1702 ASSERT_EQ(info->osr_ast_id().ToInt(), |
| 1703 code->TranslatePcOffsetToAstId(info->osr_pc_offset()).ToInt()); |
| 1704 ASSERT_NE(INTERRUPT, GetBackEdgeState(isolate, code, pc)); |
| 1702 Code* patch = isolate->builtins()->builtin(Builtins::kOsrAfterStackCheck); | 1705 Code* patch = isolate->builtins()->builtin(Builtins::kOsrAfterStackCheck); |
| 1703 PatchAt(code, pc, OSR_AFTER_STACK_CHECK, patch); | 1706 PatchAt(code, pc, OSR_AFTER_STACK_CHECK, patch); |
| 1704 } | 1707 } |
| 1705 | 1708 |
| 1706 | 1709 |
| 1707 void BackEdgeTable::RemoveStackCheck(CompilationInfo* info) { | 1710 void BackEdgeTable::RemoveStackCheck(CompilationInfo* info) { |
| 1708 DisallowHeapAllocation no_gc; | 1711 DisallowHeapAllocation no_gc; |
| 1709 Isolate* isolate = info->isolate(); | 1712 Isolate* isolate = info->isolate(); |
| 1710 Code* code = info->shared_info()->code(); | 1713 Code* code = *info->osr_patched_code(); |
| 1711 Address pc = code->instruction_start() + info->osr_pc_offset(); | 1714 Address pc = code->instruction_start() + info->osr_pc_offset(); |
| 1715 ASSERT_EQ(info->osr_ast_id().ToInt(), |
| 1716 code->TranslatePcOffsetToAstId(info->osr_pc_offset()).ToInt()); |
| 1712 if (GetBackEdgeState(isolate, code, pc) == OSR_AFTER_STACK_CHECK) { | 1717 if (GetBackEdgeState(isolate, code, pc) == OSR_AFTER_STACK_CHECK) { |
| 1713 Code* patch = isolate->builtins()->builtin(Builtins::kOnStackReplacement); | 1718 Code* patch = isolate->builtins()->builtin(Builtins::kOnStackReplacement); |
| 1714 PatchAt(code, pc, ON_STACK_REPLACEMENT, patch); | 1719 PatchAt(code, pc, ON_STACK_REPLACEMENT, patch); |
| 1715 } | 1720 } |
| 1716 } | 1721 } |
| 1717 | 1722 |
| 1718 | 1723 |
| 1719 #ifdef DEBUG | 1724 #ifdef DEBUG |
| 1720 bool BackEdgeTable::Verify(Isolate* isolate, | 1725 bool BackEdgeTable::Verify(Isolate* isolate, |
| 1721 Code* unoptimized, | 1726 Code* unoptimized, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1734 } | 1739 } |
| 1735 return true; | 1740 return true; |
| 1736 } | 1741 } |
| 1737 #endif // DEBUG | 1742 #endif // DEBUG |
| 1738 | 1743 |
| 1739 | 1744 |
| 1740 #undef __ | 1745 #undef __ |
| 1741 | 1746 |
| 1742 | 1747 |
| 1743 } } // namespace v8::internal | 1748 } } // namespace v8::internal |
| OLD | NEW |