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 2058 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2069 arg_count, in_loop); | 2069 arg_count, in_loop); |
2070 __ mov(ecx, Operand(esp, (arg_count + 1) * kPointerSize)); // Key. | 2070 __ mov(ecx, Operand(esp, (arg_count + 1) * kPointerSize)); // Key. |
2071 EmitCallIC(ic, mode, expr->id()); | 2071 EmitCallIC(ic, mode, expr->id()); |
2072 RecordJSReturnSite(expr); | 2072 RecordJSReturnSite(expr); |
2073 // Restore context register. | 2073 // Restore context register. |
2074 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); | 2074 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); |
2075 context()->DropAndPlug(1, eax); // Drop the key still on the stack. | 2075 context()->DropAndPlug(1, eax); // Drop the key still on the stack. |
2076 } | 2076 } |
2077 | 2077 |
2078 | 2078 |
2079 void FullCodeGenerator::EmitCallWithStub(Call* expr) { | 2079 void FullCodeGenerator::EmitCallWithStub(Call* expr, CallFunctionFlags flags) { |
2080 // Code common for calls using the call stub. | 2080 // Code common for calls using the call stub. |
2081 ZoneList<Expression*>* args = expr->arguments(); | 2081 ZoneList<Expression*>* args = expr->arguments(); |
2082 int arg_count = args->length(); | 2082 int arg_count = args->length(); |
2083 { PreservePositionScope scope(masm()->positions_recorder()); | 2083 { PreservePositionScope scope(masm()->positions_recorder()); |
2084 for (int i = 0; i < arg_count; i++) { | 2084 for (int i = 0; i < arg_count; i++) { |
2085 VisitForStackValue(args->at(i)); | 2085 VisitForStackValue(args->at(i)); |
2086 } | 2086 } |
2087 } | 2087 } |
2088 // Record source position for debugger. | 2088 // Record source position for debugger. |
2089 SetSourcePosition(expr->position()); | 2089 SetSourcePosition(expr->position()); |
2090 InLoopFlag in_loop = (loop_depth() > 0) ? IN_LOOP : NOT_IN_LOOP; | 2090 InLoopFlag in_loop = (loop_depth() > 0) ? IN_LOOP : NOT_IN_LOOP; |
2091 CallFunctionStub stub(arg_count, in_loop, RECEIVER_MIGHT_BE_VALUE); | 2091 CallFunctionStub stub(arg_count, in_loop, flags); |
2092 __ CallStub(&stub); | 2092 __ CallStub(&stub); |
2093 RecordJSReturnSite(expr); | 2093 RecordJSReturnSite(expr); |
2094 // Restore context register. | 2094 // Restore context register. |
2095 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); | 2095 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); |
2096 context()->DropAndPlug(1, eax); | 2096 context()->DropAndPlug(1, eax); |
2097 } | 2097 } |
2098 | 2098 |
2099 | 2099 |
2100 void FullCodeGenerator::EmitResolvePossiblyDirectEval(ResolveEvalFlag flag, | 2100 void FullCodeGenerator::EmitResolvePossiblyDirectEval(ResolveEvalFlag flag, |
2101 int arg_count) { | 2101 int arg_count) { |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2184 RecordJSReturnSite(expr); | 2184 RecordJSReturnSite(expr); |
2185 // Restore context register. | 2185 // Restore context register. |
2186 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); | 2186 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); |
2187 context()->DropAndPlug(1, eax); | 2187 context()->DropAndPlug(1, eax); |
2188 } else if (var != NULL && !var->is_this() && var->is_global()) { | 2188 } else if (var != NULL && !var->is_this() && var->is_global()) { |
2189 // Push global object as receiver for the call IC. | 2189 // Push global object as receiver for the call IC. |
2190 __ push(GlobalObjectOperand()); | 2190 __ push(GlobalObjectOperand()); |
2191 EmitCallWithIC(expr, var->name(), RelocInfo::CODE_TARGET_CONTEXT); | 2191 EmitCallWithIC(expr, var->name(), RelocInfo::CODE_TARGET_CONTEXT); |
2192 } else if (var != NULL && var->AsSlot() != NULL && | 2192 } else if (var != NULL && var->AsSlot() != NULL && |
2193 var->AsSlot()->type() == Slot::LOOKUP) { | 2193 var->AsSlot()->type() == Slot::LOOKUP) { |
2194 __ int3(); | |
Mads Ager (chromium)
2011/04/28 08:59:01
Whoops. :-)
Kevin Millikin (Chromium)
2011/04/28 09:00:03
Yeah, that's not the intended behavior.
| |
2194 // Call to a lookup slot (dynamically introduced variable). | 2195 // Call to a lookup slot (dynamically introduced variable). |
2195 Label slow, done; | 2196 Label slow, done; |
2196 | 2197 |
2197 { PreservePositionScope scope(masm()->positions_recorder()); | 2198 { PreservePositionScope scope(masm()->positions_recorder()); |
2198 // Generate code for loading from variables potentially shadowed | 2199 // Generate code for loading from variables potentially shadowed |
2199 // by eval-introduced variables. | 2200 // by eval-introduced variables. |
2200 EmitDynamicLoadFromSlotFastCase(var->AsSlot(), | 2201 EmitDynamicLoadFromSlotFastCase(var->AsSlot(), |
2201 NOT_INSIDE_TYPEOF, | 2202 NOT_INSIDE_TYPEOF, |
2202 &slow, | 2203 &slow, |
2203 &done); | 2204 &done); |
(...skipping 16 matching lines...) Expand all Loading... | |
2220 __ jmp(&call); | 2221 __ jmp(&call); |
2221 __ bind(&done); | 2222 __ bind(&done); |
2222 // Push function. | 2223 // Push function. |
2223 __ push(eax); | 2224 __ push(eax); |
2224 // Push global receiver. | 2225 // Push global receiver. |
2225 __ mov(ebx, GlobalObjectOperand()); | 2226 __ mov(ebx, GlobalObjectOperand()); |
2226 __ push(FieldOperand(ebx, GlobalObject::kGlobalReceiverOffset)); | 2227 __ push(FieldOperand(ebx, GlobalObject::kGlobalReceiverOffset)); |
2227 __ bind(&call); | 2228 __ bind(&call); |
2228 } | 2229 } |
2229 | 2230 |
2230 EmitCallWithStub(expr); | 2231 // The receiver is either the global receiver or a JSObject found by |
2232 // LoadContextSlot. | |
2233 EmitCallWithStub(expr, NO_CALL_FUNCTION_FLAGS); | |
2231 } else if (fun->AsProperty() != NULL) { | 2234 } else if (fun->AsProperty() != NULL) { |
2232 // Call to an object property. | 2235 // Call to an object property. |
2233 Property* prop = fun->AsProperty(); | 2236 Property* prop = fun->AsProperty(); |
2234 Literal* key = prop->key()->AsLiteral(); | 2237 Literal* key = prop->key()->AsLiteral(); |
2235 if (key != NULL && key->handle()->IsSymbol()) { | 2238 if (key != NULL && key->handle()->IsSymbol()) { |
2236 // Call to a named property, use call IC. | 2239 // Call to a named property, use call IC. |
2237 { PreservePositionScope scope(masm()->positions_recorder()); | 2240 { PreservePositionScope scope(masm()->positions_recorder()); |
2238 VisitForStackValue(prop->obj()); | 2241 VisitForStackValue(prop->obj()); |
2239 } | 2242 } |
2240 EmitCallWithIC(expr, key->handle(), RelocInfo::CODE_TARGET); | 2243 EmitCallWithIC(expr, key->handle(), RelocInfo::CODE_TARGET); |
(...skipping 17 matching lines...) Expand all Loading... | |
2258 // Record source code position for IC call. | 2261 // Record source code position for IC call. |
2259 SetSourcePosition(prop->position()); | 2262 SetSourcePosition(prop->position()); |
2260 | 2263 |
2261 Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Initialize(); | 2264 Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Initialize(); |
2262 EmitCallIC(ic, RelocInfo::CODE_TARGET, GetPropertyId(prop)); | 2265 EmitCallIC(ic, RelocInfo::CODE_TARGET, GetPropertyId(prop)); |
2263 // Push result (function). | 2266 // Push result (function). |
2264 __ push(eax); | 2267 __ push(eax); |
2265 // Push Global receiver. | 2268 // Push Global receiver. |
2266 __ mov(ecx, GlobalObjectOperand()); | 2269 __ mov(ecx, GlobalObjectOperand()); |
2267 __ push(FieldOperand(ecx, GlobalObject::kGlobalReceiverOffset)); | 2270 __ push(FieldOperand(ecx, GlobalObject::kGlobalReceiverOffset)); |
2268 EmitCallWithStub(expr); | 2271 EmitCallWithStub(expr, NO_CALL_FUNCTION_FLAGS); |
2269 } else { | 2272 } else { |
2270 { PreservePositionScope scope(masm()->positions_recorder()); | 2273 { PreservePositionScope scope(masm()->positions_recorder()); |
2271 VisitForStackValue(prop->obj()); | 2274 VisitForStackValue(prop->obj()); |
2272 } | 2275 } |
2273 EmitKeyedCallWithIC(expr, prop->key(), RelocInfo::CODE_TARGET); | 2276 EmitKeyedCallWithIC(expr, prop->key(), RelocInfo::CODE_TARGET); |
2274 } | 2277 } |
2275 } | 2278 } |
2276 } else { | 2279 } else { |
2277 { PreservePositionScope scope(masm()->positions_recorder()); | 2280 { PreservePositionScope scope(masm()->positions_recorder()); |
2278 VisitForStackValue(fun); | 2281 VisitForStackValue(fun); |
2279 } | 2282 } |
2280 // Load global receiver object. | 2283 // Load global receiver object. |
2281 __ mov(ebx, GlobalObjectOperand()); | 2284 __ mov(ebx, GlobalObjectOperand()); |
2282 __ push(FieldOperand(ebx, GlobalObject::kGlobalReceiverOffset)); | 2285 __ push(FieldOperand(ebx, GlobalObject::kGlobalReceiverOffset)); |
2283 // Emit function call. | 2286 // Emit function call. |
2284 EmitCallWithStub(expr); | 2287 EmitCallWithStub(expr, NO_CALL_FUNCTION_FLAGS); |
2285 } | 2288 } |
2286 | 2289 |
2287 #ifdef DEBUG | 2290 #ifdef DEBUG |
2288 // RecordJSReturnSite should have been called. | 2291 // RecordJSReturnSite should have been called. |
2289 ASSERT(expr->return_is_recorded_); | 2292 ASSERT(expr->return_is_recorded_); |
2290 #endif | 2293 #endif |
2291 } | 2294 } |
2292 | 2295 |
2293 | 2296 |
2294 void FullCodeGenerator::VisitCallNew(CallNew* expr) { | 2297 void FullCodeGenerator::VisitCallNew(CallNew* expr) { |
(...skipping 2039 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4334 // And return. | 4337 // And return. |
4335 __ ret(0); | 4338 __ ret(0); |
4336 } | 4339 } |
4337 | 4340 |
4338 | 4341 |
4339 #undef __ | 4342 #undef __ |
4340 | 4343 |
4341 } } // namespace v8::internal | 4344 } } // namespace v8::internal |
4342 | 4345 |
4343 #endif // V8_TARGET_ARCH_IA32 | 4346 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |