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

Side by Side Diff: src/ia32/stub-cache-ia32.cc

Issue 6711027: [Isolates] Merge 7201:7258 from bleeding_edge to isolates. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/isolates/
Patch Set: Created 9 years, 9 months 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
OLDNEW
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 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 2114 matching lines...) Expand 10 before | Expand all | Expand 10 after
2125 Object* obj; 2125 Object* obj;
2126 { MaybeObject* maybe_obj = GenerateMissBranch(); 2126 { MaybeObject* maybe_obj = GenerateMissBranch();
2127 if (!maybe_obj->ToObject(&obj)) return maybe_obj; 2127 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
2128 } 2128 }
2129 2129
2130 // Return the generated code. 2130 // Return the generated code.
2131 return (cell == NULL) ? GetCode(function) : GetCode(NORMAL, name); 2131 return (cell == NULL) ? GetCode(function) : GetCode(NORMAL, name);
2132 } 2132 }
2133 2133
2134 2134
2135 MaybeObject* CallStubCompiler::CompileFastApiCall(
2136 const CallOptimization& optimization,
2137 Object* object,
2138 JSObject* holder,
2139 JSGlobalPropertyCell* cell,
2140 JSFunction* function,
2141 String* name) {
2142 ASSERT(optimization.is_simple_api_call());
2143 // Bail out if object is a global object as we don't want to
2144 // repatch it to global receiver.
2145 if (object->IsGlobalObject()) return HEAP->undefined_value();
2146 if (cell != NULL) return HEAP->undefined_value();
2147 int depth = optimization.GetPrototypeDepthOfExpectedType(
2148 JSObject::cast(object), holder);
2149 if (depth == kInvalidProtoDepth) return HEAP->undefined_value();
2150
2151 Label miss, miss_before_stack_reserved;
2152
2153 GenerateNameCheck(name, &miss_before_stack_reserved);
2154
2155 // Get the receiver from the stack.
2156 const int argc = arguments().immediate();
2157 __ mov(edx, Operand(esp, (argc + 1) * kPointerSize));
2158
2159 // Check that the receiver isn't a smi.
2160 __ test(edx, Immediate(kSmiTagMask));
2161 __ j(zero, &miss_before_stack_reserved, not_taken);
2162
2163 __ IncrementCounter(COUNTERS->call_const(), 1);
2164 __ IncrementCounter(COUNTERS->call_const_fast_api(), 1);
2165
2166 // Allocate space for v8::Arguments implicit values. Must be initialized
2167 // before calling any runtime function.
2168 __ sub(Operand(esp), Immediate(kFastApiCallArguments * kPointerSize));
2169
2170 // Check that the maps haven't changed and find a Holder as a side effect.
2171 CheckPrototypes(JSObject::cast(object), edx, holder,
2172 ebx, eax, edi, name, depth, &miss);
2173
2174 // Move the return address on top of the stack.
2175 __ mov(eax, Operand(esp, 3 * kPointerSize));
2176 __ mov(Operand(esp, 0 * kPointerSize), eax);
2177
2178 // esp[2 * kPointerSize] is uninitialized, esp[3 * kPointerSize] contains
2179 // duplicate of return address and will be overwritten.
2180 MaybeObject* result = GenerateFastApiCall(masm(), optimization, argc);
2181 if (result->IsFailure()) return result;
2182
2183 __ bind(&miss);
2184 __ add(Operand(esp), Immediate(kFastApiCallArguments * kPointerSize));
2185
2186 __ bind(&miss_before_stack_reserved);
2187 Object* obj;
2188 { MaybeObject* maybe_obj = GenerateMissBranch();
2189 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
2190 }
2191
2192 // Return the generated code.
2193 return GetCode(function);
2194 }
2195
2196
2135 MaybeObject* CallStubCompiler::CompileCallConstant(Object* object, 2197 MaybeObject* CallStubCompiler::CompileCallConstant(Object* object,
2136 JSObject* holder, 2198 JSObject* holder,
2137 JSFunction* function, 2199 JSFunction* function,
2138 String* name, 2200 String* name,
2139 CheckType check) { 2201 CheckType check) {
2140 // ----------- S t a t e ------------- 2202 // ----------- S t a t e -------------
2141 // -- ecx : name 2203 // -- ecx : name
2142 // -- esp[0] : return address 2204 // -- esp[0] : return address
2143 // -- esp[(argc - n) * 4] : arg[n] (zero-based) 2205 // -- esp[(argc - n) * 4] : arg[n] (zero-based)
2144 // -- ... 2206 // -- ...
2145 // -- esp[(argc + 1) * 4] : receiver 2207 // -- esp[(argc + 1) * 4] : receiver
2146 // ----------------------------------- 2208 // -----------------------------------
2147 2209
2148 SharedFunctionInfo* function_info = function->shared(); 2210 if (HasCustomCallGenerator(function)) {
2149 if (function_info->HasBuiltinFunctionId()) {
2150 BuiltinFunctionId id = function_info->builtin_function_id();
2151 MaybeObject* maybe_result = CompileCustomCall( 2211 MaybeObject* maybe_result = CompileCustomCall(
2152 id, object, holder, NULL, function, name); 2212 object, holder, NULL, function, name);
2153 Object* result; 2213 Object* result;
2154 if (!maybe_result->ToObject(&result)) return maybe_result; 2214 if (!maybe_result->ToObject(&result)) return maybe_result;
2155 // undefined means bail out to regular compiler. 2215 // undefined means bail out to regular compiler.
2156 if (!result->IsUndefined()) return result; 2216 if (!result->IsUndefined()) return result;
2157 } 2217 }
2158 2218
2159 Label miss_in_smi_check; 2219 Label miss;
2160 2220
2161 GenerateNameCheck(name, &miss_in_smi_check); 2221 GenerateNameCheck(name, &miss);
2162 2222
2163 // Get the receiver from the stack. 2223 // Get the receiver from the stack.
2164 const int argc = arguments().immediate(); 2224 const int argc = arguments().immediate();
2165 __ mov(edx, Operand(esp, (argc + 1) * kPointerSize)); 2225 __ mov(edx, Operand(esp, (argc + 1) * kPointerSize));
2166 2226
2167 // Check that the receiver isn't a smi. 2227 // Check that the receiver isn't a smi.
2168 if (check != NUMBER_CHECK) { 2228 if (check != NUMBER_CHECK) {
2169 __ test(edx, Immediate(kSmiTagMask)); 2229 __ test(edx, Immediate(kSmiTagMask));
2170 __ j(zero, &miss_in_smi_check, not_taken); 2230 __ j(zero, &miss, not_taken);
2171 } 2231 }
2172 2232
2173 // Make sure that it's okay not to patch the on stack receiver 2233 // Make sure that it's okay not to patch the on stack receiver
2174 // unless we're doing a receiver map check. 2234 // unless we're doing a receiver map check.
2175 ASSERT(!object->IsGlobalObject() || check == RECEIVER_MAP_CHECK); 2235 ASSERT(!object->IsGlobalObject() || check == RECEIVER_MAP_CHECK);
2176 2236
2177 CallOptimization optimization(function); 2237 SharedFunctionInfo* function_info = function->shared();
2178 int depth = kInvalidProtoDepth;
2179 Label miss;
2180
2181 switch (check) { 2238 switch (check) {
2182 case RECEIVER_MAP_CHECK: 2239 case RECEIVER_MAP_CHECK:
2183 __ IncrementCounter(COUNTERS->call_const(), 1); 2240 __ IncrementCounter(COUNTERS->call_const(), 1);
2184 2241
2185 if (optimization.is_simple_api_call() && !object->IsGlobalObject()) {
2186 depth = optimization.GetPrototypeDepthOfExpectedType(
2187 JSObject::cast(object), holder);
2188 }
2189
2190 if (depth != kInvalidProtoDepth) {
2191 __ IncrementCounter(COUNTERS->call_const_fast_api(), 1);
2192
2193 // Allocate space for v8::Arguments implicit values. Must be initialized
2194 // before to call any runtime function.
2195 __ sub(Operand(esp), Immediate(kFastApiCallArguments * kPointerSize));
2196 }
2197
2198 // Check that the maps haven't changed. 2242 // Check that the maps haven't changed.
2199 CheckPrototypes(JSObject::cast(object), edx, holder, 2243 CheckPrototypes(JSObject::cast(object), edx, holder,
2200 ebx, eax, edi, name, depth, &miss); 2244 ebx, eax, edi, name, &miss);
2201 2245
2202 // Patch the receiver on the stack with the global proxy if 2246 // Patch the receiver on the stack with the global proxy if
2203 // necessary. 2247 // necessary.
2204 if (object->IsGlobalObject()) { 2248 if (object->IsGlobalObject()) {
2205 ASSERT(depth == kInvalidProtoDepth);
2206 __ mov(edx, FieldOperand(edx, GlobalObject::kGlobalReceiverOffset)); 2249 __ mov(edx, FieldOperand(edx, GlobalObject::kGlobalReceiverOffset));
2207 __ mov(Operand(esp, (argc + 1) * kPointerSize), edx); 2250 __ mov(Operand(esp, (argc + 1) * kPointerSize), edx);
2208 } 2251 }
2209 break; 2252 break;
2210 2253
2211 case STRING_CHECK: 2254 case STRING_CHECK:
2212 if (!function->IsBuiltin() && !function_info->strict_mode()) { 2255 if (!function->IsBuiltin() && !function_info->strict_mode()) {
2213 // Calling non-strict non-builtins with a value as the receiver 2256 // Calling non-strict non-builtins with a value as the receiver
2214 // requires boxing. 2257 // requires boxing.
2215 __ jmp(&miss); 2258 __ jmp(&miss);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
2266 CheckPrototypes(JSObject::cast(object->GetPrototype()), eax, holder, 2309 CheckPrototypes(JSObject::cast(object->GetPrototype()), eax, holder,
2267 ebx, edx, edi, name, &miss); 2310 ebx, edx, edi, name, &miss);
2268 } 2311 }
2269 break; 2312 break;
2270 } 2313 }
2271 2314
2272 default: 2315 default:
2273 UNREACHABLE(); 2316 UNREACHABLE();
2274 } 2317 }
2275 2318
2276 if (depth != kInvalidProtoDepth) { 2319 __ InvokeFunction(function, arguments(), JUMP_FUNCTION);
2277 // Move the return address on top of the stack.
2278 __ mov(eax, Operand(esp, 3 * kPointerSize));
2279 __ mov(Operand(esp, 0 * kPointerSize), eax);
2280
2281 // esp[2 * kPointerSize] is uninitialized, esp[3 * kPointerSize] contains
2282 // duplicate of return address and will be overwritten.
2283 MaybeObject* result = GenerateFastApiCall(masm(), optimization, argc);
2284 if (result->IsFailure()) return result;
2285 } else {
2286 __ InvokeFunction(function, arguments(), JUMP_FUNCTION);
2287 }
2288 2320
2289 // Handle call cache miss. 2321 // Handle call cache miss.
2290 __ bind(&miss); 2322 __ bind(&miss);
2291 if (depth != kInvalidProtoDepth) {
2292 __ add(Operand(esp), Immediate(kFastApiCallArguments * kPointerSize));
2293 }
2294 __ bind(&miss_in_smi_check);
2295 Object* obj; 2323 Object* obj;
2296 { MaybeObject* maybe_obj = GenerateMissBranch(); 2324 { MaybeObject* maybe_obj = GenerateMissBranch();
2297 if (!maybe_obj->ToObject(&obj)) return maybe_obj; 2325 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
2298 } 2326 }
2299 2327
2300 // Return the generated code. 2328 // Return the generated code.
2301 return GetCode(function); 2329 return GetCode(function);
2302 } 2330 }
2303 2331
2304 2332
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
2376 JSFunction* function, 2404 JSFunction* function,
2377 String* name) { 2405 String* name) {
2378 // ----------- S t a t e ------------- 2406 // ----------- S t a t e -------------
2379 // -- ecx : name 2407 // -- ecx : name
2380 // -- esp[0] : return address 2408 // -- esp[0] : return address
2381 // -- esp[(argc - n) * 4] : arg[n] (zero-based) 2409 // -- esp[(argc - n) * 4] : arg[n] (zero-based)
2382 // -- ... 2410 // -- ...
2383 // -- esp[(argc + 1) * 4] : receiver 2411 // -- esp[(argc + 1) * 4] : receiver
2384 // ----------------------------------- 2412 // -----------------------------------
2385 2413
2386 SharedFunctionInfo* function_info = function->shared(); 2414 if (HasCustomCallGenerator(function)) {
2387 if (function_info->HasBuiltinFunctionId()) {
2388 BuiltinFunctionId id = function_info->builtin_function_id();
2389 MaybeObject* maybe_result = CompileCustomCall( 2415 MaybeObject* maybe_result = CompileCustomCall(
2390 id, object, holder, cell, function, name); 2416 object, holder, cell, function, name);
2391 Object* result; 2417 Object* result;
2392 if (!maybe_result->ToObject(&result)) return maybe_result; 2418 if (!maybe_result->ToObject(&result)) return maybe_result;
2393 // undefined means bail out to regular compiler. 2419 // undefined means bail out to regular compiler.
2394 if (!result->IsUndefined()) return result; 2420 if (!result->IsUndefined()) return result;
2395 } 2421 }
2396 2422
2397 Label miss; 2423 Label miss;
2398 2424
2399 GenerateNameCheck(name, &miss); 2425 GenerateNameCheck(name, &miss);
2400 2426
(...skipping 1264 matching lines...) Expand 10 before | Expand all | Expand 10 after
3665 3691
3666 return GetCode(flags); 3692 return GetCode(flags);
3667 } 3693 }
3668 3694
3669 3695
3670 #undef __ 3696 #undef __
3671 3697
3672 } } // namespace v8::internal 3698 } } // namespace v8::internal
3673 3699
3674 #endif // V8_TARGET_ARCH_IA32 3700 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« src/global-handles.cc ('K') | « src/ia32/lithium-ia32.cc ('k') | src/mark-compact.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698