| OLD | NEW |
| 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 2207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2218 SetSourcePosition(expr->position()); | 2218 SetSourcePosition(expr->position()); |
| 2219 CallFunctionStub stub(arg_count, flags); | 2219 CallFunctionStub stub(arg_count, flags); |
| 2220 __ CallStub(&stub); | 2220 __ CallStub(&stub); |
| 2221 RecordJSReturnSite(expr); | 2221 RecordJSReturnSite(expr); |
| 2222 // Restore context register. | 2222 // Restore context register. |
| 2223 __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 2223 __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
| 2224 context()->DropAndPlug(1, v0); | 2224 context()->DropAndPlug(1, v0); |
| 2225 } | 2225 } |
| 2226 | 2226 |
| 2227 | 2227 |
| 2228 void FullCodeGenerator::EmitResolvePossiblyDirectEval(ResolveEvalFlag flag, | 2228 void FullCodeGenerator::EmitResolvePossiblyDirectEval(int arg_count) { |
| 2229 int arg_count) { | |
| 2230 // Push copy of the first argument or undefined if it doesn't exist. | 2229 // Push copy of the first argument or undefined if it doesn't exist. |
| 2231 if (arg_count > 0) { | 2230 if (arg_count > 0) { |
| 2232 __ lw(a1, MemOperand(sp, arg_count * kPointerSize)); | 2231 __ lw(a1, MemOperand(sp, arg_count * kPointerSize)); |
| 2233 } else { | 2232 } else { |
| 2234 __ LoadRoot(a1, Heap::kUndefinedValueRootIndex); | 2233 __ LoadRoot(a1, Heap::kUndefinedValueRootIndex); |
| 2235 } | 2234 } |
| 2236 __ push(a1); | 2235 __ push(a1); |
| 2237 | 2236 |
| 2238 // Push the receiver of the enclosing function and do runtime call. | 2237 // Push the receiver of the enclosing function and do runtime call. |
| 2239 int receiver_offset = 2 + info_->scope()->num_parameters(); | 2238 int receiver_offset = 2 + info_->scope()->num_parameters(); |
| 2240 __ lw(a1, MemOperand(fp, receiver_offset * kPointerSize)); | 2239 __ lw(a1, MemOperand(fp, receiver_offset * kPointerSize)); |
| 2241 __ push(a1); | 2240 __ push(a1); |
| 2242 // Push the strict mode flag. In harmony mode every eval call | 2241 // Push the strict mode flag. In harmony mode every eval call |
| 2243 // is a strict mode eval call. | 2242 // is a strict mode eval call. |
| 2244 StrictModeFlag strict_mode = | 2243 StrictModeFlag strict_mode = |
| 2245 FLAG_harmony_scoping ? kStrictMode : strict_mode_flag(); | 2244 FLAG_harmony_scoping ? kStrictMode : strict_mode_flag(); |
| 2246 __ li(a1, Operand(Smi::FromInt(strict_mode))); | 2245 __ li(a1, Operand(Smi::FromInt(strict_mode))); |
| 2247 __ push(a1); | 2246 __ push(a1); |
| 2248 | 2247 |
| 2249 __ CallRuntime(flag == SKIP_CONTEXT_LOOKUP | 2248 __ CallRuntime(Runtime::kResolvePossiblyDirectEval, 4); |
| 2250 ? Runtime::kResolvePossiblyDirectEvalNoLookup | |
| 2251 : Runtime::kResolvePossiblyDirectEval, 4); | |
| 2252 } | 2249 } |
| 2253 | 2250 |
| 2254 | 2251 |
| 2255 void FullCodeGenerator::VisitCall(Call* expr) { | 2252 void FullCodeGenerator::VisitCall(Call* expr) { |
| 2256 #ifdef DEBUG | 2253 #ifdef DEBUG |
| 2257 // We want to verify that RecordJSReturnSite gets called on all paths | 2254 // We want to verify that RecordJSReturnSite gets called on all paths |
| 2258 // through this function. Avoid early returns. | 2255 // through this function. Avoid early returns. |
| 2259 expr->return_is_recorded_ = false; | 2256 expr->return_is_recorded_ = false; |
| 2260 #endif | 2257 #endif |
| 2261 | 2258 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2275 { PreservePositionScope pos_scope(masm()->positions_recorder()); | 2272 { PreservePositionScope pos_scope(masm()->positions_recorder()); |
| 2276 VisitForStackValue(callee); | 2273 VisitForStackValue(callee); |
| 2277 __ LoadRoot(a2, Heap::kUndefinedValueRootIndex); | 2274 __ LoadRoot(a2, Heap::kUndefinedValueRootIndex); |
| 2278 __ push(a2); // Reserved receiver slot. | 2275 __ push(a2); // Reserved receiver slot. |
| 2279 | 2276 |
| 2280 // Push the arguments. | 2277 // Push the arguments. |
| 2281 for (int i = 0; i < arg_count; i++) { | 2278 for (int i = 0; i < arg_count; i++) { |
| 2282 VisitForStackValue(args->at(i)); | 2279 VisitForStackValue(args->at(i)); |
| 2283 } | 2280 } |
| 2284 | 2281 |
| 2285 // If we know that eval can only be shadowed by eval-introduced | |
| 2286 // variables we attempt to load the global eval function directly | |
| 2287 // in generated code. If we succeed, there is no need to perform a | |
| 2288 // context lookup in the runtime system. | |
| 2289 Label done; | |
| 2290 Variable* var = proxy->var(); | |
| 2291 if (!var->IsUnallocated() && var->mode() == DYNAMIC_GLOBAL) { | |
| 2292 Label slow; | |
| 2293 EmitLoadGlobalCheckExtensions(var, NOT_INSIDE_TYPEOF, &slow); | |
| 2294 // Push the function and resolve eval. | |
| 2295 __ push(v0); | |
| 2296 EmitResolvePossiblyDirectEval(SKIP_CONTEXT_LOOKUP, arg_count); | |
| 2297 __ jmp(&done); | |
| 2298 __ bind(&slow); | |
| 2299 } | |
| 2300 | |
| 2301 // Push a copy of the function (found below the arguments) and | 2282 // Push a copy of the function (found below the arguments) and |
| 2302 // resolve eval. | 2283 // resolve eval. |
| 2303 __ lw(a1, MemOperand(sp, (arg_count + 1) * kPointerSize)); | 2284 __ lw(a1, MemOperand(sp, (arg_count + 1) * kPointerSize)); |
| 2304 __ push(a1); | 2285 __ push(a1); |
| 2305 EmitResolvePossiblyDirectEval(PERFORM_CONTEXT_LOOKUP, arg_count); | 2286 EmitResolvePossiblyDirectEval(arg_count); |
| 2306 __ bind(&done); | |
| 2307 | 2287 |
| 2308 // The runtime call returns a pair of values in v0 (function) and | 2288 // The runtime call returns a pair of values in v0 (function) and |
| 2309 // v1 (receiver). Touch up the stack with the right values. | 2289 // v1 (receiver). Touch up the stack with the right values. |
| 2310 __ sw(v0, MemOperand(sp, (arg_count + 1) * kPointerSize)); | 2290 __ sw(v0, MemOperand(sp, (arg_count + 1) * kPointerSize)); |
| 2311 __ sw(v1, MemOperand(sp, arg_count * kPointerSize)); | 2291 __ sw(v1, MemOperand(sp, arg_count * kPointerSize)); |
| 2312 } | 2292 } |
| 2313 // Record source position for debugger. | 2293 // Record source position for debugger. |
| 2314 SetSourcePosition(expr->position()); | 2294 SetSourcePosition(expr->position()); |
| 2315 CallFunctionStub stub(arg_count, RECEIVER_MIGHT_BE_IMPLICIT); | 2295 CallFunctionStub stub(arg_count, RECEIVER_MIGHT_BE_IMPLICIT); |
| 2316 __ CallStub(&stub); | 2296 __ CallStub(&stub); |
| (...skipping 2051 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4368 *context_length = 0; | 4348 *context_length = 0; |
| 4369 return previous_; | 4349 return previous_; |
| 4370 } | 4350 } |
| 4371 | 4351 |
| 4372 | 4352 |
| 4373 #undef __ | 4353 #undef __ |
| 4374 | 4354 |
| 4375 } } // namespace v8::internal | 4355 } } // namespace v8::internal |
| 4376 | 4356 |
| 4377 #endif // V8_TARGET_ARCH_MIPS | 4357 #endif // V8_TARGET_ARCH_MIPS |
| OLD | NEW |