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

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

Issue 15993016: Remove the optimized construct stub. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix 64bit Created 7 years, 6 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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 3160 matching lines...) Expand 10 before | Expand all | Expand 10 after
3171 __ bind(&miss); 3171 __ bind(&miss);
3172 TailCallBuiltin(masm(), MissBuiltin(kind())); 3172 TailCallBuiltin(masm(), MissBuiltin(kind()));
3173 3173
3174 // Return the generated code. 3174 // Return the generated code.
3175 InlineCacheState state = 3175 InlineCacheState state =
3176 number_of_handled_maps > 1 ? POLYMORPHIC : MONOMORPHIC; 3176 number_of_handled_maps > 1 ? POLYMORPHIC : MONOMORPHIC;
3177 return GetICCode(kind(), type, name, state); 3177 return GetICCode(kind(), type, name, state);
3178 } 3178 }
3179 3179
3180 3180
3181 // Specialized stub for constructing objects from functions which only have only
3182 // simple assignments of the form this.x = ...; in their body.
3183 Handle<Code> ConstructStubCompiler::CompileConstructStub(
3184 Handle<JSFunction> function) {
3185 // ----------- S t a t e -------------
3186 // -- eax : argc
3187 // -- edi : constructor
3188 // -- esp[0] : return address
3189 // -- esp[4] : last argument
3190 // -----------------------------------
3191 Label generic_stub_call;
3192 #ifdef ENABLE_DEBUGGER_SUPPORT
3193 // Check to see whether there are any break points in the function code. If
3194 // there are jump to the generic constructor stub which calls the actual
3195 // code for the function thereby hitting the break points.
3196 __ mov(ebx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset));
3197 __ mov(ebx, FieldOperand(ebx, SharedFunctionInfo::kDebugInfoOffset));
3198 __ cmp(ebx, factory()->undefined_value());
3199 __ j(not_equal, &generic_stub_call);
3200 #endif
3201
3202 // Load the initial map and verify that it is in fact a map.
3203 // edi: constructor
3204 __ mov(ebx, FieldOperand(edi, JSFunction::kPrototypeOrInitialMapOffset));
3205 // Will both indicate a NULL and a Smi.
3206 __ JumpIfSmi(ebx, &generic_stub_call);
3207 __ CmpObjectType(ebx, MAP_TYPE, ecx);
3208 __ j(not_equal, &generic_stub_call);
3209
3210 #ifdef DEBUG
3211 // Cannot construct functions this way.
3212 // ebx: initial map
3213 __ CmpInstanceType(ebx, JS_FUNCTION_TYPE);
3214 __ Check(not_equal, "Function constructed by construct stub.");
3215 #endif
3216
3217 // Now allocate the JSObject on the heap by moving the new space allocation
3218 // top forward.
3219 // ebx: initial map
3220 ASSERT(function->has_initial_map());
3221 int instance_size = function->initial_map()->instance_size();
3222 #ifdef DEBUG
3223 __ movzx_b(ecx, FieldOperand(ebx, Map::kInstanceSizeOffset));
3224 __ shl(ecx, kPointerSizeLog2);
3225 __ cmp(ecx, Immediate(instance_size));
3226 __ Check(equal, "Instance size of initial map changed.");
3227 #endif
3228 __ Allocate(instance_size, edx, ecx, no_reg, &generic_stub_call,
3229 NO_ALLOCATION_FLAGS);
3230
3231 // Allocated the JSObject, now initialize the fields and add the heap tag.
3232 // ebx: initial map
3233 // edx: JSObject (untagged)
3234 __ mov(Operand(edx, JSObject::kMapOffset), ebx);
3235 __ mov(ebx, factory()->empty_fixed_array());
3236 __ mov(Operand(edx, JSObject::kPropertiesOffset), ebx);
3237 __ mov(Operand(edx, JSObject::kElementsOffset), ebx);
3238
3239 // Push the allocated object to the stack. This is the object that will be
3240 // returned (after it is tagged).
3241 __ push(edx);
3242
3243 // eax: argc
3244 // edx: JSObject (untagged)
3245 // Load the address of the first in-object property into edx.
3246 __ lea(edx, Operand(edx, JSObject::kHeaderSize));
3247 // Calculate the location of the first argument. The stack contains the
3248 // allocated object and the return address on top of the argc arguments.
3249 __ lea(ecx, Operand(esp, eax, times_4, 1 * kPointerSize));
3250
3251 // Use edi for holding undefined which is used in several places below.
3252 __ mov(edi, factory()->undefined_value());
3253
3254 // eax: argc
3255 // ecx: first argument
3256 // edx: first in-object property of the JSObject
3257 // edi: undefined
3258 // Fill the initialized properties with a constant value or a passed argument
3259 // depending on the this.x = ...; assignment in the function.
3260 Handle<SharedFunctionInfo> shared(function->shared());
3261 for (int i = 0; i < shared->this_property_assignments_count(); i++) {
3262 if (shared->IsThisPropertyAssignmentArgument(i)) {
3263 // Check if the argument assigned to the property is actually passed.
3264 // If argument is not passed the property is set to undefined,
3265 // otherwise find it on the stack.
3266 int arg_number = shared->GetThisPropertyAssignmentArgument(i);
3267 __ mov(ebx, edi);
3268 __ cmp(eax, arg_number);
3269 if (CpuFeatures::IsSupported(CMOV)) {
3270 CpuFeatureScope use_cmov(masm(), CMOV);
3271 __ cmov(above, ebx, Operand(ecx, arg_number * -kPointerSize));
3272 } else {
3273 Label not_passed;
3274 __ j(below_equal, &not_passed);
3275 __ mov(ebx, Operand(ecx, arg_number * -kPointerSize));
3276 __ bind(&not_passed);
3277 }
3278 // Store value in the property.
3279 __ mov(Operand(edx, i * kPointerSize), ebx);
3280 } else {
3281 // Set the property to the constant value.
3282 Handle<Object> constant(shared->GetThisPropertyAssignmentConstant(i),
3283 isolate());
3284 __ mov(Operand(edx, i * kPointerSize), Immediate(constant));
3285 }
3286 }
3287
3288 // Fill the unused in-object property fields with undefined.
3289 for (int i = shared->this_property_assignments_count();
3290 i < function->initial_map()->inobject_properties();
3291 i++) {
3292 __ mov(Operand(edx, i * kPointerSize), edi);
3293 }
3294
3295 // Move argc to ebx and retrieve and tag the JSObject to return.
3296 __ mov(ebx, eax);
3297 __ pop(eax);
3298 __ or_(eax, Immediate(kHeapObjectTag));
3299
3300 // Remove caller arguments and receiver from the stack and return.
3301 __ pop(ecx);
3302 __ lea(esp, Operand(esp, ebx, times_pointer_size, 1 * kPointerSize));
3303 __ push(ecx);
3304 Counters* counters = isolate()->counters();
3305 __ IncrementCounter(counters->constructed_objects(), 1);
3306 __ IncrementCounter(counters->constructed_objects_stub(), 1);
3307 __ ret(0);
3308
3309 // Jump to the generic stub in case the specialized code cannot handle the
3310 // construction.
3311 __ bind(&generic_stub_call);
3312 Handle<Code> code = isolate()->builtins()->JSConstructStubGeneric();
3313 __ jmp(code, RelocInfo::CODE_TARGET);
3314
3315 // Return the generated code.
3316 return GetCode();
3317 }
3318
3319
3320 #undef __ 3181 #undef __
3321 #define __ ACCESS_MASM(masm) 3182 #define __ ACCESS_MASM(masm)
3322 3183
3323 3184
3324 void KeyedLoadStubCompiler::GenerateLoadDictionaryElement( 3185 void KeyedLoadStubCompiler::GenerateLoadDictionaryElement(
3325 MacroAssembler* masm) { 3186 MacroAssembler* masm) {
3326 // ----------- S t a t e ------------- 3187 // ----------- S t a t e -------------
3327 // -- ecx : key 3188 // -- ecx : key
3328 // -- edx : receiver 3189 // -- edx : receiver
3329 // -- esp[0] : return address 3190 // -- esp[0] : return address
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
3877 TailCallBuiltin(masm, Builtins::kKeyedStoreIC_Slow); 3738 TailCallBuiltin(masm, Builtins::kKeyedStoreIC_Slow);
3878 } 3739 }
3879 } 3740 }
3880 3741
3881 3742
3882 #undef __ 3743 #undef __
3883 3744
3884 } } // namespace v8::internal 3745 } } // namespace v8::internal
3885 3746
3886 #endif // V8_TARGET_ARCH_IA32 3747 #endif // V8_TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698