Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(165)

Side by Side Diff: src/full-codegen/full-codegen.cc

Issue 1635553002: [Interpreter] Add native function literal support. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add back some skips for Arm64 Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler.cc ('k') | src/interpreter/bytecode-generator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « src/compiler.cc ('k') | src/interpreter/bytecode-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698