OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #if V8_TARGET_ARCH_IA32 | 5 #if V8_TARGET_ARCH_IA32 |
6 | 6 |
7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
9 #include "src/codegen.h" | 9 #include "src/codegen.h" |
10 #include "src/compiler.h" | 10 #include "src/compiler.h" |
(...skipping 3196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3207 | 3207 |
3208 __ JumpIfSmi(eax, if_false); | 3208 __ JumpIfSmi(eax, if_false); |
3209 __ CmpObjectType(eax, SIMD128_VALUE_TYPE, ebx); | 3209 __ CmpObjectType(eax, SIMD128_VALUE_TYPE, ebx); |
3210 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); | 3210 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); |
3211 Split(equal, if_true, if_false, fall_through); | 3211 Split(equal, if_true, if_false, fall_through); |
3212 | 3212 |
3213 context()->Plug(if_true, if_false); | 3213 context()->Plug(if_true, if_false); |
3214 } | 3214 } |
3215 | 3215 |
3216 | 3216 |
3217 void FullCodeGenerator::EmitIsStringWrapperSafeForDefaultValueOf( | |
3218 CallRuntime* expr) { | |
3219 ZoneList<Expression*>* args = expr->arguments(); | |
3220 DCHECK(args->length() == 1); | |
3221 | |
3222 VisitForAccumulatorValue(args->at(0)); | |
3223 | |
3224 Label materialize_true, materialize_false, skip_lookup; | |
3225 Label* if_true = NULL; | |
3226 Label* if_false = NULL; | |
3227 Label* fall_through = NULL; | |
3228 context()->PrepareTest(&materialize_true, &materialize_false, | |
3229 &if_true, &if_false, &fall_through); | |
3230 | |
3231 __ AssertNotSmi(eax); | |
3232 | |
3233 // Check whether this map has already been checked to be safe for default | |
3234 // valueOf. | |
3235 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset)); | |
3236 __ test_b(FieldOperand(ebx, Map::kBitField2Offset), | |
3237 1 << Map::kStringWrapperSafeForDefaultValueOf); | |
3238 __ j(not_zero, &skip_lookup); | |
3239 | |
3240 // Check for fast case object. Return false for slow case objects. | |
3241 __ mov(ecx, FieldOperand(eax, JSObject::kPropertiesOffset)); | |
3242 __ mov(ecx, FieldOperand(ecx, HeapObject::kMapOffset)); | |
3243 __ cmp(ecx, isolate()->factory()->hash_table_map()); | |
3244 __ j(equal, if_false); | |
3245 | |
3246 // Look for valueOf string in the descriptor array, and indicate false if | |
3247 // found. Since we omit an enumeration index check, if it is added via a | |
3248 // transition that shares its descriptor array, this is a false positive. | |
3249 Label entry, loop, done; | |
3250 | |
3251 // Skip loop if no descriptors are valid. | |
3252 __ NumberOfOwnDescriptors(ecx, ebx); | |
3253 __ cmp(ecx, 0); | |
3254 __ j(equal, &done); | |
3255 | |
3256 __ LoadInstanceDescriptors(ebx, ebx); | |
3257 // ebx: descriptor array. | |
3258 // ecx: valid entries in the descriptor array. | |
3259 // Calculate the end of the descriptor array. | |
3260 STATIC_ASSERT(kSmiTag == 0); | |
3261 STATIC_ASSERT(kSmiTagSize == 1); | |
3262 STATIC_ASSERT(kPointerSize == 4); | |
3263 __ imul(ecx, ecx, DescriptorArray::kDescriptorSize); | |
3264 __ lea(ecx, Operand(ebx, ecx, times_4, DescriptorArray::kFirstOffset)); | |
3265 // Calculate location of the first key name. | |
3266 __ add(ebx, Immediate(DescriptorArray::kFirstOffset)); | |
3267 // Loop through all the keys in the descriptor array. If one of these is the | |
3268 // internalized string "valueOf" the result is false. | |
3269 __ jmp(&entry); | |
3270 __ bind(&loop); | |
3271 __ mov(edx, FieldOperand(ebx, 0)); | |
3272 __ cmp(edx, isolate()->factory()->valueOf_string()); | |
3273 __ j(equal, if_false); | |
3274 __ add(ebx, Immediate(DescriptorArray::kDescriptorSize * kPointerSize)); | |
3275 __ bind(&entry); | |
3276 __ cmp(ebx, ecx); | |
3277 __ j(not_equal, &loop); | |
3278 | |
3279 __ bind(&done); | |
3280 | |
3281 // Reload map as register ebx was used as temporary above. | |
3282 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset)); | |
3283 | |
3284 // Set the bit in the map to indicate that there is no local valueOf field. | |
3285 __ or_(FieldOperand(ebx, Map::kBitField2Offset), | |
3286 Immediate(1 << Map::kStringWrapperSafeForDefaultValueOf)); | |
3287 | |
3288 __ bind(&skip_lookup); | |
3289 | |
3290 // If a valueOf property is not found on the object check that its | |
3291 // prototype is the un-modified String prototype. If not result is false. | |
3292 __ mov(ecx, FieldOperand(ebx, Map::kPrototypeOffset)); | |
3293 __ JumpIfSmi(ecx, if_false); | |
3294 __ mov(ecx, FieldOperand(ecx, HeapObject::kMapOffset)); | |
3295 __ mov(edx, Operand(esi, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); | |
3296 __ mov(edx, | |
3297 FieldOperand(edx, GlobalObject::kNativeContextOffset)); | |
3298 __ cmp(ecx, | |
3299 ContextOperand(edx, | |
3300 Context::STRING_FUNCTION_PROTOTYPE_MAP_INDEX)); | |
3301 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); | |
3302 Split(equal, if_true, if_false, fall_through); | |
3303 | |
3304 context()->Plug(if_true, if_false); | |
3305 } | |
3306 | |
3307 | |
3308 void FullCodeGenerator::EmitIsFunction(CallRuntime* expr) { | 3217 void FullCodeGenerator::EmitIsFunction(CallRuntime* expr) { |
3309 ZoneList<Expression*>* args = expr->arguments(); | 3218 ZoneList<Expression*>* args = expr->arguments(); |
3310 DCHECK(args->length() == 1); | 3219 DCHECK(args->length() == 1); |
3311 | 3220 |
3312 VisitForAccumulatorValue(args->at(0)); | 3221 VisitForAccumulatorValue(args->at(0)); |
3313 | 3222 |
3314 Label materialize_true, materialize_false; | 3223 Label materialize_true, materialize_false; |
3315 Label* if_true = NULL; | 3224 Label* if_true = NULL; |
3316 Label* if_false = NULL; | 3225 Label* if_false = NULL; |
3317 Label* fall_through = NULL; | 3226 Label* fall_through = NULL; |
(...skipping 1924 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5242 Assembler::target_address_at(call_target_address, | 5151 Assembler::target_address_at(call_target_address, |
5243 unoptimized_code)); | 5152 unoptimized_code)); |
5244 return OSR_AFTER_STACK_CHECK; | 5153 return OSR_AFTER_STACK_CHECK; |
5245 } | 5154 } |
5246 | 5155 |
5247 | 5156 |
5248 } // namespace internal | 5157 } // namespace internal |
5249 } // namespace v8 | 5158 } // namespace v8 |
5250 | 5159 |
5251 #endif // V8_TARGET_ARCH_IA32 | 5160 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |