| OLD | NEW |
| 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 3125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3136 | 3136 |
| 3137 __ bind(&miss); | 3137 __ bind(&miss); |
| 3138 TailCallBuiltin(masm(), MissBuiltin(kind())); | 3138 TailCallBuiltin(masm(), MissBuiltin(kind())); |
| 3139 | 3139 |
| 3140 // Return the generated code. | 3140 // Return the generated code. |
| 3141 return GetICCode( | 3141 return GetICCode( |
| 3142 kind(), Code::NORMAL, factory()->empty_string(), POLYMORPHIC); | 3142 kind(), Code::NORMAL, factory()->empty_string(), POLYMORPHIC); |
| 3143 } | 3143 } |
| 3144 | 3144 |
| 3145 | 3145 |
| 3146 Handle<Code> ConstructStubCompiler::CompileConstructStub( | |
| 3147 Handle<JSFunction> function) { | |
| 3148 // a0 : argc | |
| 3149 // a1 : constructor | |
| 3150 // ra : return address | |
| 3151 // [sp] : last argument | |
| 3152 Label generic_stub_call; | |
| 3153 | |
| 3154 // Use t7 for holding undefined which is used in several places below. | |
| 3155 __ LoadRoot(t7, Heap::kUndefinedValueRootIndex); | |
| 3156 | |
| 3157 #ifdef ENABLE_DEBUGGER_SUPPORT | |
| 3158 // Check to see whether there are any break points in the function code. If | |
| 3159 // there are jump to the generic constructor stub which calls the actual | |
| 3160 // code for the function thereby hitting the break points. | |
| 3161 __ lw(t5, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); | |
| 3162 __ lw(a2, FieldMemOperand(t5, SharedFunctionInfo::kDebugInfoOffset)); | |
| 3163 __ Branch(&generic_stub_call, ne, a2, Operand(t7)); | |
| 3164 #endif | |
| 3165 | |
| 3166 // Load the initial map and verify that it is in fact a map. | |
| 3167 // a1: constructor function | |
| 3168 // t7: undefined | |
| 3169 __ lw(a2, FieldMemOperand(a1, JSFunction::kPrototypeOrInitialMapOffset)); | |
| 3170 __ JumpIfSmi(a2, &generic_stub_call); | |
| 3171 __ GetObjectType(a2, a3, t0); | |
| 3172 __ Branch(&generic_stub_call, ne, t0, Operand(MAP_TYPE)); | |
| 3173 | |
| 3174 #ifdef DEBUG | |
| 3175 // Cannot construct functions this way. | |
| 3176 // a0: argc | |
| 3177 // a1: constructor function | |
| 3178 // a2: initial map | |
| 3179 // t7: undefined | |
| 3180 __ lbu(a3, FieldMemOperand(a2, Map::kInstanceTypeOffset)); | |
| 3181 __ Check(ne, "Function constructed by construct stub.", | |
| 3182 a3, Operand(JS_FUNCTION_TYPE)); | |
| 3183 #endif | |
| 3184 | |
| 3185 // Now allocate the JSObject in new space. | |
| 3186 // a0: argc | |
| 3187 // a1: constructor function | |
| 3188 // a2: initial map | |
| 3189 // t7: undefined | |
| 3190 ASSERT(function->has_initial_map()); | |
| 3191 __ lbu(a3, FieldMemOperand(a2, Map::kInstanceSizeOffset)); | |
| 3192 #ifdef DEBUG | |
| 3193 int instance_size = function->initial_map()->instance_size(); | |
| 3194 __ Check(eq, "Instance size of initial map changed.", | |
| 3195 a3, Operand(instance_size >> kPointerSizeLog2)); | |
| 3196 #endif | |
| 3197 __ Allocate(a3, t4, t5, t6, &generic_stub_call, SIZE_IN_WORDS); | |
| 3198 | |
| 3199 // Allocated the JSObject, now initialize the fields. Map is set to initial | |
| 3200 // map and properties and elements are set to empty fixed array. | |
| 3201 // a0: argc | |
| 3202 // a1: constructor function | |
| 3203 // a2: initial map | |
| 3204 // a3: object size (in words) | |
| 3205 // t4: JSObject (not tagged) | |
| 3206 // t7: undefined | |
| 3207 __ LoadRoot(t6, Heap::kEmptyFixedArrayRootIndex); | |
| 3208 __ mov(t5, t4); | |
| 3209 __ sw(a2, MemOperand(t5, JSObject::kMapOffset)); | |
| 3210 __ sw(t6, MemOperand(t5, JSObject::kPropertiesOffset)); | |
| 3211 __ sw(t6, MemOperand(t5, JSObject::kElementsOffset)); | |
| 3212 __ Addu(t5, t5, Operand(3 * kPointerSize)); | |
| 3213 ASSERT_EQ(0 * kPointerSize, JSObject::kMapOffset); | |
| 3214 ASSERT_EQ(1 * kPointerSize, JSObject::kPropertiesOffset); | |
| 3215 ASSERT_EQ(2 * kPointerSize, JSObject::kElementsOffset); | |
| 3216 | |
| 3217 | |
| 3218 // Calculate the location of the first argument. The stack contains only the | |
| 3219 // argc arguments. | |
| 3220 __ sll(a1, a0, kPointerSizeLog2); | |
| 3221 __ Addu(a1, a1, sp); | |
| 3222 | |
| 3223 // Fill all the in-object properties with undefined. | |
| 3224 // a0: argc | |
| 3225 // a1: first argument | |
| 3226 // a3: object size (in words) | |
| 3227 // t4: JSObject (not tagged) | |
| 3228 // t5: First in-object property of JSObject (not tagged) | |
| 3229 // t7: undefined | |
| 3230 // Fill the initialized properties with a constant value or a passed argument | |
| 3231 // depending on the this.x = ...; assignment in the function. | |
| 3232 Handle<SharedFunctionInfo> shared(function->shared()); | |
| 3233 for (int i = 0; i < shared->this_property_assignments_count(); i++) { | |
| 3234 if (shared->IsThisPropertyAssignmentArgument(i)) { | |
| 3235 Label not_passed, next; | |
| 3236 // Check if the argument assigned to the property is actually passed. | |
| 3237 int arg_number = shared->GetThisPropertyAssignmentArgument(i); | |
| 3238 __ Branch(¬_passed, less_equal, a0, Operand(arg_number)); | |
| 3239 // Argument passed - find it on the stack. | |
| 3240 __ lw(a2, MemOperand(a1, (arg_number + 1) * -kPointerSize)); | |
| 3241 __ sw(a2, MemOperand(t5)); | |
| 3242 __ Addu(t5, t5, kPointerSize); | |
| 3243 __ jmp(&next); | |
| 3244 __ bind(¬_passed); | |
| 3245 // Set the property to undefined. | |
| 3246 __ sw(t7, MemOperand(t5)); | |
| 3247 __ Addu(t5, t5, Operand(kPointerSize)); | |
| 3248 __ bind(&next); | |
| 3249 } else { | |
| 3250 // Set the property to the constant value. | |
| 3251 Handle<Object> constant( | |
| 3252 shared->GetThisPropertyAssignmentConstant(i), isolate()); | |
| 3253 __ li(a2, Operand(constant)); | |
| 3254 __ sw(a2, MemOperand(t5)); | |
| 3255 __ Addu(t5, t5, kPointerSize); | |
| 3256 } | |
| 3257 } | |
| 3258 | |
| 3259 // Fill the unused in-object property fields with undefined. | |
| 3260 for (int i = shared->this_property_assignments_count(); | |
| 3261 i < function->initial_map()->inobject_properties(); | |
| 3262 i++) { | |
| 3263 __ sw(t7, MemOperand(t5)); | |
| 3264 __ Addu(t5, t5, kPointerSize); | |
| 3265 } | |
| 3266 | |
| 3267 // a0: argc | |
| 3268 // t4: JSObject (not tagged) | |
| 3269 // Move argc to a1 and the JSObject to return to v0 and tag it. | |
| 3270 __ mov(a1, a0); | |
| 3271 __ mov(v0, t4); | |
| 3272 __ Or(v0, v0, Operand(kHeapObjectTag)); | |
| 3273 | |
| 3274 // v0: JSObject | |
| 3275 // a1: argc | |
| 3276 // Remove caller arguments and receiver from the stack and return. | |
| 3277 __ sll(t0, a1, kPointerSizeLog2); | |
| 3278 __ Addu(sp, sp, t0); | |
| 3279 __ Addu(sp, sp, Operand(kPointerSize)); | |
| 3280 Counters* counters = isolate()->counters(); | |
| 3281 __ IncrementCounter(counters->constructed_objects(), 1, a1, a2); | |
| 3282 __ IncrementCounter(counters->constructed_objects_stub(), 1, a1, a2); | |
| 3283 __ Ret(); | |
| 3284 | |
| 3285 // Jump to the generic stub in case the specialized code cannot handle the | |
| 3286 // construction. | |
| 3287 __ bind(&generic_stub_call); | |
| 3288 Handle<Code> generic_construct_stub = | |
| 3289 isolate()->builtins()->JSConstructStubGeneric(); | |
| 3290 __ Jump(generic_construct_stub, RelocInfo::CODE_TARGET); | |
| 3291 | |
| 3292 // Return the generated code. | |
| 3293 return GetCode(); | |
| 3294 } | |
| 3295 | |
| 3296 | |
| 3297 #undef __ | 3146 #undef __ |
| 3298 #define __ ACCESS_MASM(masm) | 3147 #define __ ACCESS_MASM(masm) |
| 3299 | 3148 |
| 3300 | 3149 |
| 3301 void KeyedLoadStubCompiler::GenerateLoadDictionaryElement( | 3150 void KeyedLoadStubCompiler::GenerateLoadDictionaryElement( |
| 3302 MacroAssembler* masm) { | 3151 MacroAssembler* masm) { |
| 3303 // ---------- S t a t e -------------- | 3152 // ---------- S t a t e -------------- |
| 3304 // -- ra : return address | 3153 // -- ra : return address |
| 3305 // -- a0 : key | 3154 // -- a0 : key |
| 3306 // -- a1 : receiver | 3155 // -- a1 : receiver |
| (...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3903 TailCallBuiltin(masm, Builtins::kKeyedStoreIC_Slow); | 3752 TailCallBuiltin(masm, Builtins::kKeyedStoreIC_Slow); |
| 3904 } | 3753 } |
| 3905 } | 3754 } |
| 3906 | 3755 |
| 3907 | 3756 |
| 3908 #undef __ | 3757 #undef __ |
| 3909 | 3758 |
| 3910 } } // namespace v8::internal | 3759 } } // namespace v8::internal |
| 3911 | 3760 |
| 3912 #endif // V8_TARGET_ARCH_MIPS | 3761 #endif // V8_TARGET_ARCH_MIPS |
| OLD | NEW |