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-numbering.h" | 7 #include "src/ast/ast-numbering.h" |
8 #include "src/ast/ast.h" | 8 #include "src/ast/ast.h" |
9 #include "src/ast/prettyprinter.h" | 9 #include "src/ast/prettyprinter.h" |
10 #include "src/ast/scopes.h" | 10 #include "src/ast/scopes.h" |
(...skipping 1009 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1020 NestedStatement* current = nesting_stack_; | 1020 NestedStatement* current = nesting_stack_; |
1021 int context_length = 0; | 1021 int context_length = 0; |
1022 while (current != NULL) { | 1022 while (current != NULL) { |
1023 if (HasStackOverflow()) return; | 1023 if (HasStackOverflow()) return; |
1024 current = current->Exit(&context_length); | 1024 current = current->Exit(&context_length); |
1025 } | 1025 } |
1026 EmitReturnSequence(); | 1026 EmitReturnSequence(); |
1027 } | 1027 } |
1028 | 1028 |
1029 void FullCodeGenerator::EmitNewClosure(Handle<SharedFunctionInfo> info, | 1029 void FullCodeGenerator::EmitNewClosure(Handle<SharedFunctionInfo> info, |
1030 FeedbackVectorSlot slot, | |
1031 bool pretenure) { | 1030 bool pretenure) { |
1032 // If slot is invalid, then it's a native function literal and we | |
1033 // can pass the empty array or empty literal array, something like that... | |
1034 | |
1035 // If we're running with the --always-opt or the --prepare-always-opt | 1031 // If we're running with the --always-opt or the --prepare-always-opt |
1036 // flag, we need to use the runtime function so that the new function | 1032 // flag, we need to use the runtime function so that the new function |
1037 // we are creating here gets a chance to have its code optimized and | 1033 // we are creating here gets a chance to have its code optimized and |
1038 // doesn't just get a copy of the existing unoptimized code. | 1034 // doesn't just get a copy of the existing unoptimized code. |
1039 if (!FLAG_always_opt && !FLAG_prepare_always_opt && !pretenure && | 1035 if (!FLAG_always_opt && !FLAG_prepare_always_opt && !pretenure && |
1040 scope()->is_function_scope()) { | 1036 scope()->is_function_scope()) { |
1041 FastNewClosureStub stub(isolate()); | 1037 FastNewClosureStub stub(isolate()); |
1042 __ Move(stub.GetCallInterfaceDescriptor().GetRegisterParameter(0), info); | 1038 __ Move(stub.GetCallInterfaceDescriptor().GetRegisterParameter(0), info); |
1043 DCHECK(!slot.IsInvalid()); | |
1044 __ EmitLoadTypeFeedbackVector( | |
1045 stub.GetCallInterfaceDescriptor().GetRegisterParameter(1)); | |
1046 __ Move(stub.GetCallInterfaceDescriptor().GetRegisterParameter(2), | |
1047 SmiFromSlot(slot)); | |
1048 __ CallStub(&stub); | 1039 __ CallStub(&stub); |
1049 } else { | 1040 } else { |
1050 __ Push(info); | 1041 __ Push(info); |
1051 __ EmitLoadTypeFeedbackVector(result_register()); | |
1052 __ Push(result_register()); | |
1053 __ Push(SmiFromSlot(slot)); | |
1054 __ CallRuntime(pretenure ? Runtime::kNewClosure_Tenured | 1042 __ CallRuntime(pretenure ? Runtime::kNewClosure_Tenured |
1055 : Runtime::kNewClosure); | 1043 : Runtime::kNewClosure); |
1056 } | 1044 } |
1057 context()->Plug(result_register()); | 1045 context()->Plug(result_register()); |
1058 } | 1046 } |
1059 | 1047 |
1060 void FullCodeGenerator::EmitNamedPropertyLoad(Property* prop) { | 1048 void FullCodeGenerator::EmitNamedPropertyLoad(Property* prop) { |
1061 SetExpressionPosition(prop); | 1049 SetExpressionPosition(prop); |
1062 Literal* key = prop->key()->AsLiteral(); | 1050 Literal* key = prop->key()->AsLiteral(); |
1063 DCHECK(!key->value()->IsSmi()); | 1051 DCHECK(!key->value()->IsSmi()); |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1305 void FullCodeGenerator::VisitFunctionLiteral(FunctionLiteral* expr) { | 1293 void FullCodeGenerator::VisitFunctionLiteral(FunctionLiteral* expr) { |
1306 Comment cmnt(masm_, "[ FunctionLiteral"); | 1294 Comment cmnt(masm_, "[ FunctionLiteral"); |
1307 | 1295 |
1308 // Build the function boilerplate and instantiate it. | 1296 // Build the function boilerplate and instantiate it. |
1309 Handle<SharedFunctionInfo> function_info = | 1297 Handle<SharedFunctionInfo> function_info = |
1310 Compiler::GetSharedFunctionInfo(expr, script(), info_, compilation_mode_); | 1298 Compiler::GetSharedFunctionInfo(expr, script(), info_, compilation_mode_); |
1311 if (function_info.is_null()) { | 1299 if (function_info.is_null()) { |
1312 SetStackOverflow(); | 1300 SetStackOverflow(); |
1313 return; | 1301 return; |
1314 } | 1302 } |
1315 EmitNewClosure(function_info, expr->LiteralFeedbackSlot(), expr->pretenure()); | 1303 EmitNewClosure(function_info, expr->pretenure()); |
1316 } | 1304 } |
1317 | 1305 |
1318 | 1306 |
1319 void FullCodeGenerator::VisitClassLiteral(ClassLiteral* lit) { | 1307 void FullCodeGenerator::VisitClassLiteral(ClassLiteral* lit) { |
1320 // Unsupported | 1308 // Unsupported |
1321 UNREACHABLE(); | 1309 UNREACHABLE(); |
1322 } | 1310 } |
1323 | 1311 |
1324 void FullCodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) { | 1312 void FullCodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) { |
1325 Comment cmnt(masm_, "[ RegExpLiteral"); | 1313 Comment cmnt(masm_, "[ RegExpLiteral"); |
(...skipping 12 matching lines...) Expand all Loading... |
1338 LoadFromFrameField(StandardFrameConstants::kContextOffset, | 1326 LoadFromFrameField(StandardFrameConstants::kContextOffset, |
1339 context_register()); | 1327 context_register()); |
1340 context()->Plug(result_register()); | 1328 context()->Plug(result_register()); |
1341 } | 1329 } |
1342 | 1330 |
1343 void FullCodeGenerator::VisitNativeFunctionLiteral( | 1331 void FullCodeGenerator::VisitNativeFunctionLiteral( |
1344 NativeFunctionLiteral* expr) { | 1332 NativeFunctionLiteral* expr) { |
1345 Comment cmnt(masm_, "[ NativeFunctionLiteral"); | 1333 Comment cmnt(masm_, "[ NativeFunctionLiteral"); |
1346 Handle<SharedFunctionInfo> shared = | 1334 Handle<SharedFunctionInfo> shared = |
1347 Compiler::GetSharedFunctionInfoForNative(expr->extension(), expr->name()); | 1335 Compiler::GetSharedFunctionInfoForNative(expr->extension(), expr->name()); |
1348 EmitNewClosure(shared, expr->LiteralFeedbackSlot(), false); | 1336 EmitNewClosure(shared, false); |
1349 } | 1337 } |
1350 | 1338 |
1351 | 1339 |
1352 void FullCodeGenerator::VisitThrow(Throw* expr) { | 1340 void FullCodeGenerator::VisitThrow(Throw* expr) { |
1353 Comment cmnt(masm_, "[ Throw"); | 1341 Comment cmnt(masm_, "[ Throw"); |
1354 VisitForStackValue(expr->exception()); | 1342 VisitForStackValue(expr->exception()); |
1355 SetExpressionPosition(expr); | 1343 SetExpressionPosition(expr); |
1356 CallRuntimeWithOperands(Runtime::kThrow); | 1344 CallRuntimeWithOperands(Runtime::kThrow); |
1357 // Never returns here. | 1345 // Never returns here. |
1358 | 1346 |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1624 return info_->has_simple_parameters(); | 1612 return info_->has_simple_parameters(); |
1625 } | 1613 } |
1626 | 1614 |
1627 FunctionLiteral* FullCodeGenerator::literal() const { return info_->literal(); } | 1615 FunctionLiteral* FullCodeGenerator::literal() const { return info_->literal(); } |
1628 | 1616 |
1629 #undef __ | 1617 #undef __ |
1630 | 1618 |
1631 | 1619 |
1632 } // namespace internal | 1620 } // namespace internal |
1633 } // namespace v8 | 1621 } // namespace v8 |
OLD | NEW |