Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(224)

Side by Side Diff: src/ia32/full-codegen-ia32.cc

Issue 8343054: Make eval consider anything on the form eval(args...) a potential direct cal (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address review comments. Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/full-codegen.h ('k') | src/mips/full-codegen-mips.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 2199 matching lines...) Expand 10 before | Expand all | Expand 10 after
2210 2210
2211 RecordJSReturnSite(expr); 2211 RecordJSReturnSite(expr);
2212 // Restore context register. 2212 // Restore context register.
2213 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); 2213 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
2214 2214
2215 decrement_stack_height(arg_count + 1); 2215 decrement_stack_height(arg_count + 1);
2216 context()->DropAndPlug(1, eax); 2216 context()->DropAndPlug(1, eax);
2217 } 2217 }
2218 2218
2219 2219
2220 void FullCodeGenerator::EmitResolvePossiblyDirectEval(ResolveEvalFlag flag, 2220 void FullCodeGenerator::EmitResolvePossiblyDirectEval(int arg_count) {
2221 int arg_count) {
2222 // Push copy of the first argument or undefined if it doesn't exist. 2221 // Push copy of the first argument or undefined if it doesn't exist.
2223 if (arg_count > 0) { 2222 if (arg_count > 0) {
2224 __ push(Operand(esp, arg_count * kPointerSize)); 2223 __ push(Operand(esp, arg_count * kPointerSize));
2225 } else { 2224 } else {
2226 __ push(Immediate(isolate()->factory()->undefined_value())); 2225 __ push(Immediate(isolate()->factory()->undefined_value()));
2227 } 2226 }
2228 2227
2229 // Push the receiver of the enclosing function. 2228 // Push the receiver of the enclosing function.
2230 __ push(Operand(ebp, (2 + info_->scope()->num_parameters()) * kPointerSize)); 2229 __ push(Operand(ebp, (2 + info_->scope()->num_parameters()) * kPointerSize));
2231 2230
2232 // Push the strict mode flag. In harmony mode every eval call 2231 // Push the strict mode flag. In harmony mode every eval call
2233 // is a strict mode eval call. 2232 // is a strict mode eval call.
2234 StrictModeFlag strict_mode = 2233 StrictModeFlag strict_mode =
2235 FLAG_harmony_scoping ? kStrictMode : strict_mode_flag(); 2234 FLAG_harmony_scoping ? kStrictMode : strict_mode_flag();
2236 __ push(Immediate(Smi::FromInt(strict_mode))); 2235 __ push(Immediate(Smi::FromInt(strict_mode)));
2237 2236
2238 __ CallRuntime(flag == SKIP_CONTEXT_LOOKUP 2237 __ CallRuntime(Runtime::kResolvePossiblyDirectEval, 4);
2239 ? Runtime::kResolvePossiblyDirectEvalNoLookup
2240 : Runtime::kResolvePossiblyDirectEval, 4);
2241 } 2238 }
2242 2239
2243 2240
2244 void FullCodeGenerator::VisitCall(Call* expr) { 2241 void FullCodeGenerator::VisitCall(Call* expr) {
2245 #ifdef DEBUG 2242 #ifdef DEBUG
2246 // We want to verify that RecordJSReturnSite gets called on all paths 2243 // We want to verify that RecordJSReturnSite gets called on all paths
2247 // through this function. Avoid early returns. 2244 // through this function. Avoid early returns.
2248 expr->return_is_recorded_ = false; 2245 expr->return_is_recorded_ = false;
2249 #endif 2246 #endif
2250 2247
(...skipping 11 matching lines...) Expand all
2262 { PreservePositionScope pos_scope(masm()->positions_recorder()); 2259 { PreservePositionScope pos_scope(masm()->positions_recorder());
2263 VisitForStackValue(callee); 2260 VisitForStackValue(callee);
2264 // Reserved receiver slot. 2261 // Reserved receiver slot.
2265 __ push(Immediate(isolate()->factory()->undefined_value())); 2262 __ push(Immediate(isolate()->factory()->undefined_value()));
2266 increment_stack_height(); 2263 increment_stack_height();
2267 // Push the arguments. 2264 // Push the arguments.
2268 for (int i = 0; i < arg_count; i++) { 2265 for (int i = 0; i < arg_count; i++) {
2269 VisitForStackValue(args->at(i)); 2266 VisitForStackValue(args->at(i));
2270 } 2267 }
2271 2268
2272 // If we know that eval can only be shadowed by eval-introduced
2273 // variables we attempt to load the global eval function directly in
2274 // generated code. If we succeed, there is no need to perform a
2275 // context lookup in the runtime system.
2276 Label done;
2277 Variable* var = proxy->var();
2278 if (!var->IsUnallocated() && var->mode() == DYNAMIC_GLOBAL) {
2279 Label slow;
2280 EmitLoadGlobalCheckExtensions(var, NOT_INSIDE_TYPEOF, &slow);
2281 // Push the function and resolve eval.
2282 __ push(eax);
2283 EmitResolvePossiblyDirectEval(SKIP_CONTEXT_LOOKUP, arg_count);
2284 __ jmp(&done);
2285 __ bind(&slow);
2286 }
2287
2288 // Push a copy of the function (found below the arguments) and 2269 // Push a copy of the function (found below the arguments) and
2289 // resolve eval. 2270 // resolve eval.
2290 __ push(Operand(esp, (arg_count + 1) * kPointerSize)); 2271 __ push(Operand(esp, (arg_count + 1) * kPointerSize));
2291 EmitResolvePossiblyDirectEval(PERFORM_CONTEXT_LOOKUP, arg_count); 2272 EmitResolvePossiblyDirectEval(arg_count);
2292 __ bind(&done);
2293 2273
2294 // The runtime call returns a pair of values in eax (function) and 2274 // The runtime call returns a pair of values in eax (function) and
2295 // edx (receiver). Touch up the stack with the right values. 2275 // edx (receiver). Touch up the stack with the right values.
2296 __ mov(Operand(esp, (arg_count + 0) * kPointerSize), edx); 2276 __ mov(Operand(esp, (arg_count + 0) * kPointerSize), edx);
2297 __ mov(Operand(esp, (arg_count + 1) * kPointerSize), eax); 2277 __ mov(Operand(esp, (arg_count + 1) * kPointerSize), eax);
2298 } 2278 }
2299 // Record source position for debugger. 2279 // Record source position for debugger.
2300 SetSourcePosition(expr->position()); 2280 SetSourcePosition(expr->position());
2301 CallFunctionStub stub(arg_count, RECEIVER_MIGHT_BE_IMPLICIT); 2281 CallFunctionStub stub(arg_count, RECEIVER_MIGHT_BE_IMPLICIT);
2302 __ CallStub(&stub); 2282 __ CallStub(&stub);
(...skipping 2121 matching lines...) Expand 10 before | Expand all | Expand 10 after
4424 *context_length = 0; 4404 *context_length = 0;
4425 return previous_; 4405 return previous_;
4426 } 4406 }
4427 4407
4428 4408
4429 #undef __ 4409 #undef __
4430 4410
4431 } } // namespace v8::internal 4411 } } // namespace v8::internal
4432 4412
4433 #endif // V8_TARGET_ARCH_IA32 4413 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/full-codegen.h ('k') | src/mips/full-codegen-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698