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

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

Issue 15993016: Remove the optimized construct stub. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments 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
« no previous file with comments | « no previous file | src/ast.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 3073 matching lines...) Expand 10 before | Expand all | Expand 10 after
3084 3084
3085 __ bind(&miss); 3085 __ bind(&miss);
3086 TailCallBuiltin(masm(), MissBuiltin(kind())); 3086 TailCallBuiltin(masm(), MissBuiltin(kind()));
3087 3087
3088 // Return the generated code. 3088 // Return the generated code.
3089 return GetICCode( 3089 return GetICCode(
3090 kind(), Code::NORMAL, factory()->empty_string(), POLYMORPHIC); 3090 kind(), Code::NORMAL, factory()->empty_string(), POLYMORPHIC);
3091 } 3091 }
3092 3092
3093 3093
3094 Handle<Code> ConstructStubCompiler::CompileConstructStub(
3095 Handle<JSFunction> function) {
3096 // ----------- S t a t e -------------
3097 // -- r0 : argc
3098 // -- r1 : constructor
3099 // -- lr : return address
3100 // -- [sp] : last argument
3101 // -----------------------------------
3102 Label generic_stub_call;
3103
3104 // Use r7 for holding undefined which is used in several places below.
3105 __ LoadRoot(r7, Heap::kUndefinedValueRootIndex);
3106
3107 #ifdef ENABLE_DEBUGGER_SUPPORT
3108 // Check to see whether there are any break points in the function code. If
3109 // there are jump to the generic constructor stub which calls the actual
3110 // code for the function thereby hitting the break points.
3111 __ ldr(r2, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset));
3112 __ ldr(r2, FieldMemOperand(r2, SharedFunctionInfo::kDebugInfoOffset));
3113 __ cmp(r2, r7);
3114 __ b(ne, &generic_stub_call);
3115 #endif
3116
3117 // Load the initial map and verify that it is in fact a map.
3118 // r1: constructor function
3119 // r7: undefined
3120 __ ldr(r2, FieldMemOperand(r1, JSFunction::kPrototypeOrInitialMapOffset));
3121 __ JumpIfSmi(r2, &generic_stub_call);
3122 __ CompareObjectType(r2, r3, r4, MAP_TYPE);
3123 __ b(ne, &generic_stub_call);
3124
3125 #ifdef DEBUG
3126 // Cannot construct functions this way.
3127 // r0: argc
3128 // r1: constructor function
3129 // r2: initial map
3130 // r7: undefined
3131 __ CompareInstanceType(r2, r3, JS_FUNCTION_TYPE);
3132 __ Check(ne, "Function constructed by construct stub.");
3133 #endif
3134
3135 // Now allocate the JSObject in new space.
3136 // r0: argc
3137 // r1: constructor function
3138 // r2: initial map
3139 // r7: undefined
3140 ASSERT(function->has_initial_map());
3141 __ ldrb(r3, FieldMemOperand(r2, Map::kInstanceSizeOffset));
3142 #ifdef DEBUG
3143 int instance_size = function->initial_map()->instance_size();
3144 __ cmp(r3, Operand(instance_size >> kPointerSizeLog2));
3145 __ Check(eq, "Instance size of initial map changed.");
3146 #endif
3147 __ Allocate(r3, r4, r5, r6, &generic_stub_call, SIZE_IN_WORDS);
3148
3149 // Allocated the JSObject, now initialize the fields. Map is set to initial
3150 // map and properties and elements are set to empty fixed array.
3151 // r0: argc
3152 // r1: constructor function
3153 // r2: initial map
3154 // r3: object size (in words)
3155 // r4: JSObject (not tagged)
3156 // r7: undefined
3157 __ LoadRoot(r6, Heap::kEmptyFixedArrayRootIndex);
3158 __ mov(r5, r4);
3159 ASSERT_EQ(0 * kPointerSize, JSObject::kMapOffset);
3160 __ str(r2, MemOperand(r5, kPointerSize, PostIndex));
3161 ASSERT_EQ(1 * kPointerSize, JSObject::kPropertiesOffset);
3162 __ str(r6, MemOperand(r5, kPointerSize, PostIndex));
3163 ASSERT_EQ(2 * kPointerSize, JSObject::kElementsOffset);
3164 __ str(r6, MemOperand(r5, kPointerSize, PostIndex));
3165
3166 // Calculate the location of the first argument. The stack contains only the
3167 // argc arguments.
3168 __ add(r1, sp, Operand(r0, LSL, kPointerSizeLog2));
3169
3170 // Fill all the in-object properties with undefined.
3171 // r0: argc
3172 // r1: first argument
3173 // r3: object size (in words)
3174 // r4: JSObject (not tagged)
3175 // r5: First in-object property of JSObject (not tagged)
3176 // r7: undefined
3177 // Fill the initialized properties with a constant value or a passed argument
3178 // depending on the this.x = ...; assignment in the function.
3179 Handle<SharedFunctionInfo> shared(function->shared());
3180 for (int i = 0; i < shared->this_property_assignments_count(); i++) {
3181 if (shared->IsThisPropertyAssignmentArgument(i)) {
3182 Label not_passed, next;
3183 // Check if the argument assigned to the property is actually passed.
3184 int arg_number = shared->GetThisPropertyAssignmentArgument(i);
3185 __ cmp(r0, Operand(arg_number));
3186 __ b(le, &not_passed);
3187 // Argument passed - find it on the stack.
3188 __ ldr(r2, MemOperand(r1, (arg_number + 1) * -kPointerSize));
3189 __ str(r2, MemOperand(r5, kPointerSize, PostIndex));
3190 __ b(&next);
3191 __ bind(&not_passed);
3192 // Set the property to undefined.
3193 __ str(r7, MemOperand(r5, kPointerSize, PostIndex));
3194 __ bind(&next);
3195 } else {
3196 // Set the property to the constant value.
3197 Handle<Object> constant(shared->GetThisPropertyAssignmentConstant(i),
3198 isolate());
3199 __ mov(r2, Operand(constant));
3200 __ str(r2, MemOperand(r5, kPointerSize, PostIndex));
3201 }
3202 }
3203
3204 // Fill the unused in-object property fields with undefined.
3205 for (int i = shared->this_property_assignments_count();
3206 i < function->initial_map()->inobject_properties();
3207 i++) {
3208 __ str(r7, MemOperand(r5, kPointerSize, PostIndex));
3209 }
3210
3211 // r0: argc
3212 // r4: JSObject (not tagged)
3213 // Move argc to r1 and the JSObject to return to r0 and tag it.
3214 __ mov(r1, r0);
3215 __ mov(r0, r4);
3216 __ orr(r0, r0, Operand(kHeapObjectTag));
3217
3218 // r0: JSObject
3219 // r1: argc
3220 // Remove caller arguments and receiver from the stack and return.
3221 __ add(sp, sp, Operand(r1, LSL, kPointerSizeLog2));
3222 __ add(sp, sp, Operand(kPointerSize));
3223 Counters* counters = isolate()->counters();
3224 __ IncrementCounter(counters->constructed_objects(), 1, r1, r2);
3225 __ IncrementCounter(counters->constructed_objects_stub(), 1, r1, r2);
3226 __ Jump(lr);
3227
3228 // Jump to the generic stub in case the specialized code cannot handle the
3229 // construction.
3230 __ bind(&generic_stub_call);
3231 Handle<Code> code = isolate()->builtins()->JSConstructStubGeneric();
3232 __ Jump(code, RelocInfo::CODE_TARGET);
3233
3234 // Return the generated code.
3235 return GetCode();
3236 }
3237
3238
3239 #undef __ 3094 #undef __
3240 #define __ ACCESS_MASM(masm) 3095 #define __ ACCESS_MASM(masm)
3241 3096
3242 3097
3243 void KeyedLoadStubCompiler::GenerateLoadDictionaryElement( 3098 void KeyedLoadStubCompiler::GenerateLoadDictionaryElement(
3244 MacroAssembler* masm) { 3099 MacroAssembler* masm) {
3245 // ---------- S t a t e -------------- 3100 // ---------- S t a t e --------------
3246 // -- lr : return address 3101 // -- lr : return address
3247 // -- r0 : key 3102 // -- r0 : key
3248 // -- r1 : receiver 3103 // -- r1 : receiver
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after
3782 TailCallBuiltin(masm, Builtins::kKeyedStoreIC_Slow); 3637 TailCallBuiltin(masm, Builtins::kKeyedStoreIC_Slow);
3783 } 3638 }
3784 } 3639 }
3785 3640
3786 3641
3787 #undef __ 3642 #undef __
3788 3643
3789 } } // namespace v8::internal 3644 } } // namespace v8::internal
3790 3645
3791 #endif // V8_TARGET_ARCH_ARM 3646 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « no previous file | src/ast.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698