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