| 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/full-codegen/full-codegen.h" | 5 #include "src/full-codegen/full-codegen.h" |
| 6 | 6 |
| 7 #include "src/ast/ast.h" | 7 #include "src/ast/ast.h" |
| 8 #include "src/ast/ast-numbering.h" | 8 #include "src/ast/ast-numbering.h" |
| 9 #include "src/ast/prettyprinter.h" | 9 #include "src/ast/prettyprinter.h" |
| 10 #include "src/ast/scopeinfo.h" | 10 #include "src/ast/scopeinfo.h" |
| (...skipping 1330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1341 } | 1341 } |
| 1342 } | 1342 } |
| 1343 | 1343 |
| 1344 context()->Plug(result_register()); | 1344 context()->Plug(result_register()); |
| 1345 } | 1345 } |
| 1346 | 1346 |
| 1347 | 1347 |
| 1348 void FullCodeGenerator::VisitNativeFunctionLiteral( | 1348 void FullCodeGenerator::VisitNativeFunctionLiteral( |
| 1349 NativeFunctionLiteral* expr) { | 1349 NativeFunctionLiteral* expr) { |
| 1350 Comment cmnt(masm_, "[ NativeFunctionLiteral"); | 1350 Comment cmnt(masm_, "[ NativeFunctionLiteral"); |
| 1351 | |
| 1352 v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate()); | |
| 1353 | |
| 1354 // Compute the function template for the native function. | |
| 1355 Handle<String> name = expr->name(); | |
| 1356 v8::Local<v8::FunctionTemplate> fun_template = | |
| 1357 expr->extension()->GetNativeFunctionTemplate(v8_isolate, | |
| 1358 v8::Utils::ToLocal(name)); | |
| 1359 DCHECK(!fun_template.IsEmpty()); | |
| 1360 | |
| 1361 // Instantiate the function and create a shared function info from it. | |
| 1362 Handle<JSFunction> fun = Handle<JSFunction>::cast(Utils::OpenHandle( | |
| 1363 *fun_template->GetFunction(v8_isolate->GetCurrentContext()) | |
| 1364 .ToLocalChecked())); | |
| 1365 const int literals = fun->NumberOfLiterals(); | |
| 1366 Handle<Code> code = Handle<Code>(fun->shared()->code()); | |
| 1367 Handle<Code> construct_stub = Handle<Code>(fun->shared()->construct_stub()); | |
| 1368 Handle<SharedFunctionInfo> shared = | 1351 Handle<SharedFunctionInfo> shared = |
| 1369 isolate()->factory()->NewSharedFunctionInfo( | 1352 Compiler::GetSharedFunctionInfoForNative(expr->extension(), expr->name()); |
| 1370 name, literals, FunctionKind::kNormalFunction, code, | |
| 1371 Handle<ScopeInfo>(fun->shared()->scope_info()), | |
| 1372 Handle<TypeFeedbackVector>(fun->shared()->feedback_vector())); | |
| 1373 shared->set_construct_stub(*construct_stub); | |
| 1374 | |
| 1375 // Copy the function data to the shared function info. | |
| 1376 shared->set_function_data(fun->shared()->function_data()); | |
| 1377 int parameters = fun->shared()->internal_formal_parameter_count(); | |
| 1378 shared->set_internal_formal_parameter_count(parameters); | |
| 1379 | |
| 1380 EmitNewClosure(shared, false); | 1353 EmitNewClosure(shared, false); |
| 1381 } | 1354 } |
| 1382 | 1355 |
| 1383 | 1356 |
| 1384 void FullCodeGenerator::VisitThrow(Throw* expr) { | 1357 void FullCodeGenerator::VisitThrow(Throw* expr) { |
| 1385 Comment cmnt(masm_, "[ Throw"); | 1358 Comment cmnt(masm_, "[ Throw"); |
| 1386 VisitForStackValue(expr->exception()); | 1359 VisitForStackValue(expr->exception()); |
| 1387 SetExpressionPosition(expr); | 1360 SetExpressionPosition(expr); |
| 1388 __ CallRuntime(Runtime::kThrow); | 1361 __ CallRuntime(Runtime::kThrow); |
| 1389 // Never returns here. | 1362 // Never returns here. |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1735 return var->mode() == CONST_LEGACY || var->scope()->is_nonlinear() || | 1708 return var->mode() == CONST_LEGACY || var->scope()->is_nonlinear() || |
| 1736 var->initializer_position() >= proxy->position(); | 1709 var->initializer_position() >= proxy->position(); |
| 1737 } | 1710 } |
| 1738 | 1711 |
| 1739 | 1712 |
| 1740 #undef __ | 1713 #undef __ |
| 1741 | 1714 |
| 1742 | 1715 |
| 1743 } // namespace internal | 1716 } // namespace internal |
| 1744 } // namespace v8 | 1717 } // namespace v8 |
| OLD | NEW |