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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 DebuggerStatement* stmt) { | 190 DebuggerStatement* stmt) { |
191 // The debugger statement is breakable. | 191 // The debugger statement is breakable. |
192 is_breakable_ = true; | 192 is_breakable_ = true; |
193 } | 193 } |
194 | 194 |
195 | 195 |
196 void BreakableStatementChecker::VisitFunctionLiteral(FunctionLiteral* expr) { | 196 void BreakableStatementChecker::VisitFunctionLiteral(FunctionLiteral* expr) { |
197 } | 197 } |
198 | 198 |
199 | 199 |
200 void BreakableStatementChecker::VisitSharedFunctionInfoLiteral( | 200 void BreakableStatementChecker::VisitNativeFunctionLiteral( |
201 SharedFunctionInfoLiteral* expr) { | 201 NativeFunctionLiteral* expr) { |
202 } | 202 } |
203 | 203 |
204 | 204 |
205 void BreakableStatementChecker::VisitConditional(Conditional* expr) { | 205 void BreakableStatementChecker::VisitConditional(Conditional* expr) { |
206 } | 206 } |
207 | 207 |
208 | 208 |
209 void BreakableStatementChecker::VisitVariableProxy(VariableProxy* expr) { | 209 void BreakableStatementChecker::VisitVariableProxy(VariableProxy* expr) { |
210 } | 210 } |
211 | 211 |
(...skipping 1348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1560 Handle<SharedFunctionInfo> function_info = | 1560 Handle<SharedFunctionInfo> function_info = |
1561 Compiler::BuildFunctionInfo(expr, script()); | 1561 Compiler::BuildFunctionInfo(expr, script()); |
1562 if (function_info.is_null()) { | 1562 if (function_info.is_null()) { |
1563 SetStackOverflow(); | 1563 SetStackOverflow(); |
1564 return; | 1564 return; |
1565 } | 1565 } |
1566 EmitNewClosure(function_info, expr->pretenure()); | 1566 EmitNewClosure(function_info, expr->pretenure()); |
1567 } | 1567 } |
1568 | 1568 |
1569 | 1569 |
1570 void FullCodeGenerator::VisitSharedFunctionInfoLiteral( | 1570 void FullCodeGenerator::VisitNativeFunctionLiteral( |
1571 SharedFunctionInfoLiteral* expr) { | 1571 NativeFunctionLiteral* expr) { |
1572 Comment cmnt(masm_, "[ SharedFunctionInfoLiteral"); | 1572 Comment cmnt(masm_, "[ NativeFunctionLiteral"); |
1573 EmitNewClosure(expr->shared_function_info(), false); | 1573 |
| 1574 // Compute the function template for the native function. |
| 1575 Handle<String> name = expr->name(); |
| 1576 v8::Handle<v8::FunctionTemplate> fun_template = |
| 1577 info_->extension()->GetNativeFunction(v8::Utils::ToLocal(name)); |
| 1578 ASSERT(!fun_template.IsEmpty()); |
| 1579 |
| 1580 // Instantiate the function and create a shared function info from it. |
| 1581 Handle<JSFunction> fun = Utils::OpenHandle(*fun_template->GetFunction()); |
| 1582 const int literals = fun->NumberOfLiterals(); |
| 1583 Handle<Code> code = Handle<Code>(fun->shared()->code()); |
| 1584 Handle<Code> construct_stub = Handle<Code>(fun->shared()->construct_stub()); |
| 1585 bool is_generator = false; |
| 1586 Handle<SharedFunctionInfo> shared = |
| 1587 isolate()->factory()->NewSharedFunctionInfo(name, literals, is_generator, |
| 1588 code, Handle<ScopeInfo>(fun->shared()->scope_info())); |
| 1589 shared->set_construct_stub(*construct_stub); |
| 1590 |
| 1591 // Copy the function data to the shared function info. |
| 1592 shared->set_function_data(fun->shared()->function_data()); |
| 1593 int parameters = fun->shared()->formal_parameter_count(); |
| 1594 shared->set_formal_parameter_count(parameters); |
| 1595 |
| 1596 EmitNewClosure(shared, false); |
1574 } | 1597 } |
1575 | 1598 |
1576 | 1599 |
1577 void FullCodeGenerator::VisitThrow(Throw* expr) { | 1600 void FullCodeGenerator::VisitThrow(Throw* expr) { |
1578 Comment cmnt(masm_, "[ Throw"); | 1601 Comment cmnt(masm_, "[ Throw"); |
1579 VisitForStackValue(expr->exception()); | 1602 VisitForStackValue(expr->exception()); |
1580 __ CallRuntime(Runtime::kThrow, 1); | 1603 __ CallRuntime(Runtime::kThrow, 1); |
1581 // Never returns here. | 1604 // Never returns here. |
1582 } | 1605 } |
1583 | 1606 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1706 } | 1729 } |
1707 return true; | 1730 return true; |
1708 } | 1731 } |
1709 #endif // DEBUG | 1732 #endif // DEBUG |
1710 | 1733 |
1711 | 1734 |
1712 #undef __ | 1735 #undef __ |
1713 | 1736 |
1714 | 1737 |
1715 } } // namespace v8::internal | 1738 } } // namespace v8::internal |
OLD | NEW |