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 2211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2222 #ifdef ENABLE_DEBUGGER_SUPPORT | 2222 #ifdef ENABLE_DEBUGGER_SUPPORT |
2223 // Spill everything, even constants, to the frame. | 2223 // Spill everything, even constants, to the frame. |
2224 frame_->SpillAll(); | 2224 frame_->SpillAll(); |
2225 | 2225 |
2226 frame_->DebugBreak(); | 2226 frame_->DebugBreak(); |
2227 // Ignore the return value. | 2227 // Ignore the return value. |
2228 #endif | 2228 #endif |
2229 } | 2229 } |
2230 | 2230 |
2231 | 2231 |
2232 void CodeGenerator::InstantiateBoilerplate(Handle<JSFunction> boilerplate) { | 2232 void CodeGenerator::InstantiateFunction( |
2233 ASSERT(boilerplate->IsBoilerplate()); | 2233 Handle<SharedFunctionInfo> function_info) { |
2234 | |
2235 // The inevitable call will sync frame elements to memory anyway, so | 2234 // The inevitable call will sync frame elements to memory anyway, so |
2236 // we do it eagerly to allow us to push the arguments directly into | 2235 // we do it eagerly to allow us to push the arguments directly into |
2237 // place. | 2236 // place. |
2238 frame_->SyncRange(0, frame_->element_count() - 1); | 2237 frame_->SyncRange(0, frame_->element_count() - 1); |
2239 | 2238 |
2240 // Use the fast case closure allocation code that allocates in new | 2239 // Use the fast case closure allocation code that allocates in new |
2241 // space for nested functions that don't need literals cloning. | 2240 // space for nested functions that don't need literals cloning. |
2242 if (scope()->is_function_scope() && boilerplate->NumberOfLiterals() == 0) { | 2241 if (false && scope()->is_function_scope() && |
| 2242 function_info->num_literals() == 0) { |
2243 FastNewClosureStub stub; | 2243 FastNewClosureStub stub; |
2244 frame_->Push(boilerplate); | 2244 frame_->Push(function_info); |
2245 Result answer = frame_->CallStub(&stub, 1); | 2245 Result answer = frame_->CallStub(&stub, 1); |
2246 frame_->Push(&answer); | 2246 frame_->Push(&answer); |
2247 } else { | 2247 } else { |
2248 // Call the runtime to instantiate the function boilerplate | 2248 // Call the runtime to instantiate the function boilerplate |
2249 // object. | 2249 // object. |
2250 frame_->EmitPush(rsi); | 2250 frame_->EmitPush(rsi); |
2251 frame_->EmitPush(boilerplate); | 2251 frame_->EmitPush(function_info); |
2252 Result result = frame_->CallRuntime(Runtime::kNewClosure, 2); | 2252 Result result = frame_->CallRuntime(Runtime::kNewClosure, 2); |
2253 frame_->Push(&result); | 2253 frame_->Push(&result); |
2254 } | 2254 } |
2255 } | 2255 } |
2256 | 2256 |
2257 | 2257 |
2258 void CodeGenerator::VisitFunctionLiteral(FunctionLiteral* node) { | 2258 void CodeGenerator::VisitFunctionLiteral(FunctionLiteral* node) { |
2259 Comment cmnt(masm_, "[ FunctionLiteral"); | 2259 Comment cmnt(masm_, "[ FunctionLiteral"); |
2260 | 2260 |
2261 // Build the function boilerplate and instantiate it. | 2261 // Build the function info and instantiate it. |
2262 Handle<JSFunction> boilerplate = | 2262 Handle<SharedFunctionInfo> function_info = |
2263 Compiler::BuildBoilerplate(node, script(), this); | 2263 Compiler::BuildFunctionInfo(node, script(), this); |
2264 // Check for stack-overflow exception. | 2264 // Check for stack-overflow exception. |
2265 if (HasStackOverflow()) return; | 2265 if (HasStackOverflow()) return; |
2266 InstantiateBoilerplate(boilerplate); | 2266 InstantiateFunction(function_info); |
2267 } | 2267 } |
2268 | 2268 |
2269 | 2269 |
2270 void CodeGenerator::VisitFunctionBoilerplateLiteral( | 2270 void CodeGenerator::VisitSharedFunctionInfoLiteral( |
2271 FunctionBoilerplateLiteral* node) { | 2271 SharedFunctionInfoLiteral* node) { |
2272 Comment cmnt(masm_, "[ FunctionBoilerplateLiteral"); | 2272 Comment cmnt(masm_, "[ SharedFunctionInfoLiteral"); |
2273 InstantiateBoilerplate(node->boilerplate()); | 2273 InstantiateFunction(node->shared_function_info()); |
2274 } | 2274 } |
2275 | 2275 |
2276 | 2276 |
2277 void CodeGenerator::VisitConditional(Conditional* node) { | 2277 void CodeGenerator::VisitConditional(Conditional* node) { |
2278 Comment cmnt(masm_, "[ Conditional"); | 2278 Comment cmnt(masm_, "[ Conditional"); |
2279 JumpTarget then; | 2279 JumpTarget then; |
2280 JumpTarget else_; | 2280 JumpTarget else_; |
2281 JumpTarget exit; | 2281 JumpTarget exit; |
2282 ControlDestination dest(&then, &else_, true); | 2282 ControlDestination dest(&then, &else_, true); |
2283 LoadCondition(node->condition(), &dest, true); | 2283 LoadCondition(node->condition(), &dest, true); |
(...skipping 7706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9990 // Call the function from C++. | 9990 // Call the function from C++. |
9991 return FUNCTION_CAST<ModuloFunction>(buffer); | 9991 return FUNCTION_CAST<ModuloFunction>(buffer); |
9992 } | 9992 } |
9993 | 9993 |
9994 #endif | 9994 #endif |
9995 | 9995 |
9996 | 9996 |
9997 #undef __ | 9997 #undef __ |
9998 | 9998 |
9999 } } // namespace v8::internal | 9999 } } // namespace v8::internal |
OLD | NEW |