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