OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 4879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4890 // Spill everything, even constants, to the frame. | 4890 // Spill everything, even constants, to the frame. |
4891 frame_->SpillAll(); | 4891 frame_->SpillAll(); |
4892 | 4892 |
4893 frame_->DebugBreak(); | 4893 frame_->DebugBreak(); |
4894 // Ignore the return value. | 4894 // Ignore the return value. |
4895 #endif | 4895 #endif |
4896 } | 4896 } |
4897 | 4897 |
4898 | 4898 |
4899 Result CodeGenerator::InstantiateFunction( | 4899 Result CodeGenerator::InstantiateFunction( |
4900 Handle<SharedFunctionInfo> function_info) { | 4900 Handle<SharedFunctionInfo> function_info, |
| 4901 bool pretenure) { |
4901 // The inevitable call will sync frame elements to memory anyway, so | 4902 // The inevitable call will sync frame elements to memory anyway, so |
4902 // we do it eagerly to allow us to push the arguments directly into | 4903 // we do it eagerly to allow us to push the arguments directly into |
4903 // place. | 4904 // place. |
4904 frame()->SyncRange(0, frame()->element_count() - 1); | 4905 frame()->SyncRange(0, frame()->element_count() - 1); |
4905 | 4906 |
4906 // Use the fast case closure allocation code that allocates in new | 4907 // Use the fast case closure allocation code that allocates in new |
4907 // space for nested functions that don't need literals cloning. | 4908 // space for nested functions that don't need literals cloning. |
4908 if (scope()->is_function_scope() && function_info->num_literals() == 0) { | 4909 if (scope()->is_function_scope() && |
| 4910 function_info->num_literals() == 0 && |
| 4911 !pretenure) { |
4909 FastNewClosureStub stub; | 4912 FastNewClosureStub stub; |
4910 frame()->EmitPush(Immediate(function_info)); | 4913 frame()->EmitPush(Immediate(function_info)); |
4911 return frame()->CallStub(&stub, 1); | 4914 return frame()->CallStub(&stub, 1); |
4912 } else { | 4915 } else { |
4913 // Call the runtime to instantiate the function based on the | 4916 // Call the runtime to instantiate the function based on the |
4914 // shared function info. | 4917 // shared function info. |
4915 frame()->EmitPush(esi); | 4918 frame()->EmitPush(esi); |
4916 frame()->EmitPush(Immediate(function_info)); | 4919 frame()->EmitPush(Immediate(function_info)); |
4917 return frame()->CallRuntime(Runtime::kNewClosure, 2); | 4920 frame()->EmitPush(Immediate(pretenure |
| 4921 ? Factory::true_value() |
| 4922 : Factory::false_value())); |
| 4923 return frame()->CallRuntime(Runtime::kNewClosure, 3); |
4918 } | 4924 } |
4919 } | 4925 } |
4920 | 4926 |
4921 | 4927 |
4922 void CodeGenerator::VisitFunctionLiteral(FunctionLiteral* node) { | 4928 void CodeGenerator::VisitFunctionLiteral(FunctionLiteral* node) { |
4923 Comment cmnt(masm_, "[ FunctionLiteral"); | 4929 Comment cmnt(masm_, "[ FunctionLiteral"); |
4924 ASSERT(!in_safe_int32_mode()); | 4930 ASSERT(!in_safe_int32_mode()); |
4925 // Build the function info and instantiate it. | 4931 // Build the function info and instantiate it. |
4926 Handle<SharedFunctionInfo> function_info = | 4932 Handle<SharedFunctionInfo> function_info = |
4927 Compiler::BuildFunctionInfo(node, script()); | 4933 Compiler::BuildFunctionInfo(node, script()); |
4928 // Check for stack-overflow exception. | 4934 // Check for stack-overflow exception. |
4929 if (function_info.is_null()) { | 4935 if (function_info.is_null()) { |
4930 SetStackOverflow(); | 4936 SetStackOverflow(); |
4931 return; | 4937 return; |
4932 } | 4938 } |
4933 Result result = InstantiateFunction(function_info); | 4939 Result result = InstantiateFunction(function_info, node->pretenure()); |
4934 frame()->Push(&result); | 4940 frame()->Push(&result); |
4935 } | 4941 } |
4936 | 4942 |
4937 | 4943 |
4938 void CodeGenerator::VisitSharedFunctionInfoLiteral( | 4944 void CodeGenerator::VisitSharedFunctionInfoLiteral( |
4939 SharedFunctionInfoLiteral* node) { | 4945 SharedFunctionInfoLiteral* node) { |
4940 ASSERT(!in_safe_int32_mode()); | 4946 ASSERT(!in_safe_int32_mode()); |
4941 Comment cmnt(masm_, "[ SharedFunctionInfoLiteral"); | 4947 Comment cmnt(masm_, "[ SharedFunctionInfoLiteral"); |
4942 Result result = InstantiateFunction(node->shared_function_info()); | 4948 Result result = InstantiateFunction(node->shared_function_info(), false); |
4943 frame()->Push(&result); | 4949 frame()->Push(&result); |
4944 } | 4950 } |
4945 | 4951 |
4946 | 4952 |
4947 void CodeGenerator::VisitConditional(Conditional* node) { | 4953 void CodeGenerator::VisitConditional(Conditional* node) { |
4948 Comment cmnt(masm_, "[ Conditional"); | 4954 Comment cmnt(masm_, "[ Conditional"); |
4949 ASSERT(!in_safe_int32_mode()); | 4955 ASSERT(!in_safe_int32_mode()); |
4950 JumpTarget then; | 4956 JumpTarget then; |
4951 JumpTarget else_; | 4957 JumpTarget else_; |
4952 JumpTarget exit; | 4958 JumpTarget exit; |
(...skipping 5313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10266 masm.GetCode(&desc); | 10272 masm.GetCode(&desc); |
10267 // Call the function from C++. | 10273 // Call the function from C++. |
10268 return FUNCTION_CAST<MemCopyFunction>(buffer); | 10274 return FUNCTION_CAST<MemCopyFunction>(buffer); |
10269 } | 10275 } |
10270 | 10276 |
10271 #undef __ | 10277 #undef __ |
10272 | 10278 |
10273 } } // namespace v8::internal | 10279 } } // namespace v8::internal |
10274 | 10280 |
10275 #endif // V8_TARGET_ARCH_IA32 | 10281 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |