| 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_X87 | 5 #if V8_TARGET_ARCH_X87 |
| 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 3186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3197 | 3197 |
| 3198 __ JumpIfSmi(eax, if_false); | 3198 __ JumpIfSmi(eax, if_false); |
| 3199 __ CmpObjectType(eax, SIMD128_VALUE_TYPE, ebx); | 3199 __ CmpObjectType(eax, SIMD128_VALUE_TYPE, ebx); |
| 3200 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); | 3200 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); |
| 3201 Split(equal, if_true, if_false, fall_through); | 3201 Split(equal, if_true, if_false, fall_through); |
| 3202 | 3202 |
| 3203 context()->Plug(if_true, if_false); | 3203 context()->Plug(if_true, if_false); |
| 3204 } | 3204 } |
| 3205 | 3205 |
| 3206 | 3206 |
| 3207 void FullCodeGenerator::EmitIsStringWrapperSafeForDefaultValueOf( | |
| 3208 CallRuntime* expr) { | |
| 3209 ZoneList<Expression*>* args = expr->arguments(); | |
| 3210 DCHECK(args->length() == 1); | |
| 3211 | |
| 3212 VisitForAccumulatorValue(args->at(0)); | |
| 3213 | |
| 3214 Label materialize_true, materialize_false, skip_lookup; | |
| 3215 Label* if_true = NULL; | |
| 3216 Label* if_false = NULL; | |
| 3217 Label* fall_through = NULL; | |
| 3218 context()->PrepareTest(&materialize_true, &materialize_false, | |
| 3219 &if_true, &if_false, &fall_through); | |
| 3220 | |
| 3221 __ AssertNotSmi(eax); | |
| 3222 | |
| 3223 // Check whether this map has already been checked to be safe for default | |
| 3224 // valueOf. | |
| 3225 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset)); | |
| 3226 __ test_b(FieldOperand(ebx, Map::kBitField2Offset), | |
| 3227 1 << Map::kStringWrapperSafeForDefaultValueOf); | |
| 3228 __ j(not_zero, &skip_lookup); | |
| 3229 | |
| 3230 // Check for fast case object. Return false for slow case objects. | |
| 3231 __ mov(ecx, FieldOperand(eax, JSObject::kPropertiesOffset)); | |
| 3232 __ mov(ecx, FieldOperand(ecx, HeapObject::kMapOffset)); | |
| 3233 __ cmp(ecx, isolate()->factory()->hash_table_map()); | |
| 3234 __ j(equal, if_false); | |
| 3235 | |
| 3236 // Look for valueOf string in the descriptor array, and indicate false if | |
| 3237 // found. Since we omit an enumeration index check, if it is added via a | |
| 3238 // transition that shares its descriptor array, this is a false positive. | |
| 3239 Label entry, loop, done; | |
| 3240 | |
| 3241 // Skip loop if no descriptors are valid. | |
| 3242 __ NumberOfOwnDescriptors(ecx, ebx); | |
| 3243 __ cmp(ecx, 0); | |
| 3244 __ j(equal, &done); | |
| 3245 | |
| 3246 __ LoadInstanceDescriptors(ebx, ebx); | |
| 3247 // ebx: descriptor array. | |
| 3248 // ecx: valid entries in the descriptor array. | |
| 3249 // Calculate the end of the descriptor array. | |
| 3250 STATIC_ASSERT(kSmiTag == 0); | |
| 3251 STATIC_ASSERT(kSmiTagSize == 1); | |
| 3252 STATIC_ASSERT(kPointerSize == 4); | |
| 3253 __ imul(ecx, ecx, DescriptorArray::kDescriptorSize); | |
| 3254 __ lea(ecx, Operand(ebx, ecx, times_4, DescriptorArray::kFirstOffset)); | |
| 3255 // Calculate location of the first key name. | |
| 3256 __ add(ebx, Immediate(DescriptorArray::kFirstOffset)); | |
| 3257 // Loop through all the keys in the descriptor array. If one of these is the | |
| 3258 // internalized string "valueOf" the result is false. | |
| 3259 __ jmp(&entry); | |
| 3260 __ bind(&loop); | |
| 3261 __ mov(edx, FieldOperand(ebx, 0)); | |
| 3262 __ cmp(edx, isolate()->factory()->valueOf_string()); | |
| 3263 __ j(equal, if_false); | |
| 3264 __ add(ebx, Immediate(DescriptorArray::kDescriptorSize * kPointerSize)); | |
| 3265 __ bind(&entry); | |
| 3266 __ cmp(ebx, ecx); | |
| 3267 __ j(not_equal, &loop); | |
| 3268 | |
| 3269 __ bind(&done); | |
| 3270 | |
| 3271 // Reload map as register ebx was used as temporary above. | |
| 3272 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset)); | |
| 3273 | |
| 3274 // Set the bit in the map to indicate that there is no local valueOf field. | |
| 3275 __ or_(FieldOperand(ebx, Map::kBitField2Offset), | |
| 3276 Immediate(1 << Map::kStringWrapperSafeForDefaultValueOf)); | |
| 3277 | |
| 3278 __ bind(&skip_lookup); | |
| 3279 | |
| 3280 // If a valueOf property is not found on the object check that its | |
| 3281 // prototype is the un-modified String prototype. If not result is false. | |
| 3282 __ mov(ecx, FieldOperand(ebx, Map::kPrototypeOffset)); | |
| 3283 __ JumpIfSmi(ecx, if_false); | |
| 3284 __ mov(ecx, FieldOperand(ecx, HeapObject::kMapOffset)); | |
| 3285 __ mov(edx, Operand(esi, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); | |
| 3286 __ mov(edx, | |
| 3287 FieldOperand(edx, GlobalObject::kNativeContextOffset)); | |
| 3288 __ cmp(ecx, | |
| 3289 ContextOperand(edx, | |
| 3290 Context::STRING_FUNCTION_PROTOTYPE_MAP_INDEX)); | |
| 3291 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); | |
| 3292 Split(equal, if_true, if_false, fall_through); | |
| 3293 | |
| 3294 context()->Plug(if_true, if_false); | |
| 3295 } | |
| 3296 | |
| 3297 | |
| 3298 void FullCodeGenerator::EmitIsFunction(CallRuntime* expr) { | 3207 void FullCodeGenerator::EmitIsFunction(CallRuntime* expr) { |
| 3299 ZoneList<Expression*>* args = expr->arguments(); | 3208 ZoneList<Expression*>* args = expr->arguments(); |
| 3300 DCHECK(args->length() == 1); | 3209 DCHECK(args->length() == 1); |
| 3301 | 3210 |
| 3302 VisitForAccumulatorValue(args->at(0)); | 3211 VisitForAccumulatorValue(args->at(0)); |
| 3303 | 3212 |
| 3304 Label materialize_true, materialize_false; | 3213 Label materialize_true, materialize_false; |
| 3305 Label* if_true = NULL; | 3214 Label* if_true = NULL; |
| 3306 Label* if_false = NULL; | 3215 Label* if_false = NULL; |
| 3307 Label* fall_through = NULL; | 3216 Label* fall_through = NULL; |
| (...skipping 1923 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5231 Assembler::target_address_at(call_target_address, | 5140 Assembler::target_address_at(call_target_address, |
| 5232 unoptimized_code)); | 5141 unoptimized_code)); |
| 5233 return OSR_AFTER_STACK_CHECK; | 5142 return OSR_AFTER_STACK_CHECK; |
| 5234 } | 5143 } |
| 5235 | 5144 |
| 5236 | 5145 |
| 5237 } // namespace internal | 5146 } // namespace internal |
| 5238 } // namespace v8 | 5147 } // namespace v8 |
| 5239 | 5148 |
| 5240 #endif // V8_TARGET_ARCH_X87 | 5149 #endif // V8_TARGET_ARCH_X87 |
| OLD | NEW |