| 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 2182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2193 SetSourcePosition(expr->position()); | 2193 SetSourcePosition(expr->position()); |
| 2194 CallFunctionStub stub(arg_count, flags); | 2194 CallFunctionStub stub(arg_count, flags); |
| 2195 __ CallStub(&stub); | 2195 __ CallStub(&stub); |
| 2196 RecordJSReturnSite(expr); | 2196 RecordJSReturnSite(expr); |
| 2197 // Restore context register. | 2197 // Restore context register. |
| 2198 __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 2198 __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
| 2199 context()->DropAndPlug(1, r0); | 2199 context()->DropAndPlug(1, r0); |
| 2200 } | 2200 } |
| 2201 | 2201 |
| 2202 | 2202 |
| 2203 void FullCodeGenerator::EmitResolvePossiblyDirectEval(ResolveEvalFlag flag, | 2203 void FullCodeGenerator::EmitResolvePossiblyDirectEval(int arg_count) { |
| 2204 int arg_count) { | |
| 2205 // Push copy of the first argument or undefined if it doesn't exist. | 2204 // Push copy of the first argument or undefined if it doesn't exist. |
| 2206 if (arg_count > 0) { | 2205 if (arg_count > 0) { |
| 2207 __ ldr(r1, MemOperand(sp, arg_count * kPointerSize)); | 2206 __ ldr(r1, MemOperand(sp, arg_count * kPointerSize)); |
| 2208 } else { | 2207 } else { |
| 2209 __ LoadRoot(r1, Heap::kUndefinedValueRootIndex); | 2208 __ LoadRoot(r1, Heap::kUndefinedValueRootIndex); |
| 2210 } | 2209 } |
| 2211 __ push(r1); | 2210 __ push(r1); |
| 2212 | 2211 |
| 2213 // Push the receiver of the enclosing function and do runtime call. | 2212 // Push the receiver of the enclosing function and do runtime call. |
| 2214 int receiver_offset = 2 + info_->scope()->num_parameters(); | 2213 int receiver_offset = 2 + info_->scope()->num_parameters(); |
| 2215 __ ldr(r1, MemOperand(fp, receiver_offset * kPointerSize)); | 2214 __ ldr(r1, MemOperand(fp, receiver_offset * kPointerSize)); |
| 2216 __ push(r1); | 2215 __ push(r1); |
| 2217 // Push the strict mode flag. In harmony mode every eval call | 2216 // Push the strict mode flag. In harmony mode every eval call |
| 2218 // is a strict mode eval call. | 2217 // is a strict mode eval call. |
| 2219 StrictModeFlag strict_mode = | 2218 StrictModeFlag strict_mode = |
| 2220 FLAG_harmony_scoping ? kStrictMode : strict_mode_flag(); | 2219 FLAG_harmony_scoping ? kStrictMode : strict_mode_flag(); |
| 2221 __ mov(r1, Operand(Smi::FromInt(strict_mode))); | 2220 __ mov(r1, Operand(Smi::FromInt(strict_mode))); |
| 2222 __ push(r1); | 2221 __ push(r1); |
| 2223 | 2222 |
| 2224 __ CallRuntime(flag == SKIP_CONTEXT_LOOKUP | 2223 __ CallRuntime(Runtime::kResolvePossiblyDirectEval, 4); |
| 2225 ? Runtime::kResolvePossiblyDirectEvalNoLookup | |
| 2226 : Runtime::kResolvePossiblyDirectEval, 4); | |
| 2227 } | 2224 } |
| 2228 | 2225 |
| 2229 | 2226 |
| 2230 void FullCodeGenerator::VisitCall(Call* expr) { | 2227 void FullCodeGenerator::VisitCall(Call* expr) { |
| 2231 #ifdef DEBUG | 2228 #ifdef DEBUG |
| 2232 // We want to verify that RecordJSReturnSite gets called on all paths | 2229 // We want to verify that RecordJSReturnSite gets called on all paths |
| 2233 // through this function. Avoid early returns. | 2230 // through this function. Avoid early returns. |
| 2234 expr->return_is_recorded_ = false; | 2231 expr->return_is_recorded_ = false; |
| 2235 #endif | 2232 #endif |
| 2236 | 2233 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2250 { PreservePositionScope pos_scope(masm()->positions_recorder()); | 2247 { PreservePositionScope pos_scope(masm()->positions_recorder()); |
| 2251 VisitForStackValue(callee); | 2248 VisitForStackValue(callee); |
| 2252 __ LoadRoot(r2, Heap::kUndefinedValueRootIndex); | 2249 __ LoadRoot(r2, Heap::kUndefinedValueRootIndex); |
| 2253 __ push(r2); // Reserved receiver slot. | 2250 __ push(r2); // Reserved receiver slot. |
| 2254 | 2251 |
| 2255 // Push the arguments. | 2252 // Push the arguments. |
| 2256 for (int i = 0; i < arg_count; i++) { | 2253 for (int i = 0; i < arg_count; i++) { |
| 2257 VisitForStackValue(args->at(i)); | 2254 VisitForStackValue(args->at(i)); |
| 2258 } | 2255 } |
| 2259 | 2256 |
| 2260 // If we know that eval can only be shadowed by eval-introduced | |
| 2261 // variables we attempt to load the global eval function directly | |
| 2262 // in generated code. If we succeed, there is no need to perform a | |
| 2263 // context lookup in the runtime system. | |
| 2264 Label done; | |
| 2265 Variable* var = proxy->var(); | |
| 2266 if (!var->IsUnallocated() && var->mode() == DYNAMIC_GLOBAL) { | |
| 2267 Label slow; | |
| 2268 EmitLoadGlobalCheckExtensions(var, NOT_INSIDE_TYPEOF, &slow); | |
| 2269 // Push the function and resolve eval. | |
| 2270 __ push(r0); | |
| 2271 EmitResolvePossiblyDirectEval(SKIP_CONTEXT_LOOKUP, arg_count); | |
| 2272 __ jmp(&done); | |
| 2273 __ bind(&slow); | |
| 2274 } | |
| 2275 | |
| 2276 // Push a copy of the function (found below the arguments) and | 2257 // Push a copy of the function (found below the arguments) and |
| 2277 // resolve eval. | 2258 // resolve eval. |
| 2278 __ ldr(r1, MemOperand(sp, (arg_count + 1) * kPointerSize)); | 2259 __ ldr(r1, MemOperand(sp, (arg_count + 1) * kPointerSize)); |
| 2279 __ push(r1); | 2260 __ push(r1); |
| 2280 EmitResolvePossiblyDirectEval(PERFORM_CONTEXT_LOOKUP, arg_count); | 2261 EmitResolvePossiblyDirectEval(arg_count); |
| 2281 __ bind(&done); | |
| 2282 | 2262 |
| 2283 // The runtime call returns a pair of values in r0 (function) and | 2263 // The runtime call returns a pair of values in r0 (function) and |
| 2284 // r1 (receiver). Touch up the stack with the right values. | 2264 // r1 (receiver). Touch up the stack with the right values. |
| 2285 __ str(r0, MemOperand(sp, (arg_count + 1) * kPointerSize)); | 2265 __ str(r0, MemOperand(sp, (arg_count + 1) * kPointerSize)); |
| 2286 __ str(r1, MemOperand(sp, arg_count * kPointerSize)); | 2266 __ str(r1, MemOperand(sp, arg_count * kPointerSize)); |
| 2287 } | 2267 } |
| 2288 | 2268 |
| 2289 // Record source position for debugger. | 2269 // Record source position for debugger. |
| 2290 SetSourcePosition(expr->position()); | 2270 SetSourcePosition(expr->position()); |
| 2291 CallFunctionStub stub(arg_count, RECEIVER_MIGHT_BE_IMPLICIT); | 2271 CallFunctionStub stub(arg_count, RECEIVER_MIGHT_BE_IMPLICIT); |
| (...skipping 2047 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4339 *context_length = 0; | 4319 *context_length = 0; |
| 4340 return previous_; | 4320 return previous_; |
| 4341 } | 4321 } |
| 4342 | 4322 |
| 4343 | 4323 |
| 4344 #undef __ | 4324 #undef __ |
| 4345 | 4325 |
| 4346 } } // namespace v8::internal | 4326 } } // namespace v8::internal |
| 4347 | 4327 |
| 4348 #endif // V8_TARGET_ARCH_ARM | 4328 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |