| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 2519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2530 | 2530 |
| 2531 | 2531 |
| 2532 MaybeObject* KeyedStoreStubCompiler::CompileStoreElement(Map* receiver_map) { | 2532 MaybeObject* KeyedStoreStubCompiler::CompileStoreElement(Map* receiver_map) { |
| 2533 // ----------- S t a t e ------------- | 2533 // ----------- S t a t e ------------- |
| 2534 // -- rax : value | 2534 // -- rax : value |
| 2535 // -- rcx : key | 2535 // -- rcx : key |
| 2536 // -- rdx : receiver | 2536 // -- rdx : receiver |
| 2537 // -- rsp[0] : return address | 2537 // -- rsp[0] : return address |
| 2538 // ----------------------------------- | 2538 // ----------------------------------- |
| 2539 Code* stub; | 2539 Code* stub; |
| 2540 JSObject::ElementsKind elements_kind = receiver_map->elements_kind(); | 2540 ElementsKind elements_kind = receiver_map->elements_kind(); |
| 2541 bool is_js_array = receiver_map->instance_type() == JS_ARRAY_TYPE; | 2541 bool is_js_array = receiver_map->instance_type() == JS_ARRAY_TYPE; |
| 2542 MaybeObject* maybe_stub = | 2542 MaybeObject* maybe_stub = |
| 2543 KeyedStoreElementStub(is_js_array, elements_kind).TryGetCode(); | 2543 KeyedStoreElementStub(is_js_array, elements_kind).TryGetCode(); |
| 2544 if (!maybe_stub->To(&stub)) return maybe_stub; | 2544 if (!maybe_stub->To(&stub)) return maybe_stub; |
| 2545 __ DispatchMap(rdx, | 2545 __ DispatchMap(rdx, |
| 2546 Handle<Map>(receiver_map), | 2546 Handle<Map>(receiver_map), |
| 2547 Handle<Code>(stub), | 2547 Handle<Code>(stub), |
| 2548 DO_SMI_CHECK); | 2548 DO_SMI_CHECK); |
| 2549 | 2549 |
| 2550 Handle<Code> ic = isolate()->builtins()->KeyedStoreIC_Miss(); | 2550 Handle<Code> ic = isolate()->builtins()->KeyedStoreIC_Miss(); |
| (...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2989 } | 2989 } |
| 2990 | 2990 |
| 2991 | 2991 |
| 2992 MaybeObject* KeyedLoadStubCompiler::CompileLoadElement(Map* receiver_map) { | 2992 MaybeObject* KeyedLoadStubCompiler::CompileLoadElement(Map* receiver_map) { |
| 2993 // ----------- S t a t e ------------- | 2993 // ----------- S t a t e ------------- |
| 2994 // -- rax : key | 2994 // -- rax : key |
| 2995 // -- rdx : receiver | 2995 // -- rdx : receiver |
| 2996 // -- rsp[0] : return address | 2996 // -- rsp[0] : return address |
| 2997 // ----------------------------------- | 2997 // ----------------------------------- |
| 2998 Code* stub; | 2998 Code* stub; |
| 2999 JSObject::ElementsKind elements_kind = receiver_map->elements_kind(); | 2999 ElementsKind elements_kind = receiver_map->elements_kind(); |
| 3000 MaybeObject* maybe_stub = KeyedLoadElementStub(elements_kind).TryGetCode(); | 3000 MaybeObject* maybe_stub = KeyedLoadElementStub(elements_kind).TryGetCode(); |
| 3001 if (!maybe_stub->To(&stub)) return maybe_stub; | 3001 if (!maybe_stub->To(&stub)) return maybe_stub; |
| 3002 __ DispatchMap(rdx, | 3002 __ DispatchMap(rdx, |
| 3003 Handle<Map>(receiver_map), | 3003 Handle<Map>(receiver_map), |
| 3004 Handle<Code>(stub), | 3004 Handle<Code>(stub), |
| 3005 DO_SMI_CHECK); | 3005 DO_SMI_CHECK); |
| 3006 | 3006 |
| 3007 Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Miss(); | 3007 Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Miss(); |
| 3008 __ jmp(ic, RelocInfo::CODE_TARGET); | 3008 __ jmp(ic, RelocInfo::CODE_TARGET); |
| 3009 | 3009 |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3220 // -- rdx : receiver | 3220 // -- rdx : receiver |
| 3221 // -- rsp[0] : return address | 3221 // -- rsp[0] : return address |
| 3222 // ----------------------------------- | 3222 // ----------------------------------- |
| 3223 Handle<Code> miss_ic = | 3223 Handle<Code> miss_ic = |
| 3224 masm->isolate()->builtins()->KeyedLoadIC_MissForceGeneric(); | 3224 masm->isolate()->builtins()->KeyedLoadIC_MissForceGeneric(); |
| 3225 __ jmp(miss_ic, RelocInfo::CODE_TARGET); | 3225 __ jmp(miss_ic, RelocInfo::CODE_TARGET); |
| 3226 } | 3226 } |
| 3227 | 3227 |
| 3228 void KeyedLoadStubCompiler::GenerateLoadExternalArray( | 3228 void KeyedLoadStubCompiler::GenerateLoadExternalArray( |
| 3229 MacroAssembler* masm, | 3229 MacroAssembler* masm, |
| 3230 JSObject::ElementsKind elements_kind) { | 3230 ElementsKind elements_kind) { |
| 3231 // ----------- S t a t e ------------- | 3231 // ----------- S t a t e ------------- |
| 3232 // -- rax : key | 3232 // -- rax : key |
| 3233 // -- rdx : receiver | 3233 // -- rdx : receiver |
| 3234 // -- rsp[0] : return address | 3234 // -- rsp[0] : return address |
| 3235 // ----------------------------------- | 3235 // ----------------------------------- |
| 3236 Label slow, miss_force_generic; | 3236 Label slow, miss_force_generic; |
| 3237 | 3237 |
| 3238 // This stub is meant to be tail-jumped to, the receiver must already | 3238 // This stub is meant to be tail-jumped to, the receiver must already |
| 3239 // have been verified by the caller to not be a smi. | 3239 // have been verified by the caller to not be a smi. |
| 3240 | 3240 |
| 3241 // Check that the key is a smi. | 3241 // Check that the key is a smi. |
| 3242 __ JumpIfNotSmi(rax, &miss_force_generic); | 3242 __ JumpIfNotSmi(rax, &miss_force_generic); |
| 3243 | 3243 |
| 3244 // Check that the index is in range. | 3244 // Check that the index is in range. |
| 3245 __ movq(rbx, FieldOperand(rdx, JSObject::kElementsOffset)); | 3245 __ movq(rbx, FieldOperand(rdx, JSObject::kElementsOffset)); |
| 3246 __ SmiToInteger32(rcx, rax); | 3246 __ SmiToInteger32(rcx, rax); |
| 3247 __ cmpq(rax, FieldOperand(rbx, ExternalArray::kLengthOffset)); | 3247 __ cmpq(rax, FieldOperand(rbx, ExternalArray::kLengthOffset)); |
| 3248 // Unsigned comparison catches both negative and too-large values. | 3248 // Unsigned comparison catches both negative and too-large values. |
| 3249 __ j(above_equal, &miss_force_generic); | 3249 __ j(above_equal, &miss_force_generic); |
| 3250 | 3250 |
| 3251 // rax: index (as a smi) | 3251 // rax: index (as a smi) |
| 3252 // rdx: receiver (JSObject) | 3252 // rdx: receiver (JSObject) |
| 3253 // rcx: untagged index | 3253 // rcx: untagged index |
| 3254 // rbx: elements array | 3254 // rbx: elements array |
| 3255 __ movq(rbx, FieldOperand(rbx, ExternalArray::kExternalPointerOffset)); | 3255 __ movq(rbx, FieldOperand(rbx, ExternalArray::kExternalPointerOffset)); |
| 3256 // rbx: base pointer of external storage | 3256 // rbx: base pointer of external storage |
| 3257 switch (elements_kind) { | 3257 switch (elements_kind) { |
| 3258 case JSObject::EXTERNAL_BYTE_ELEMENTS: | 3258 case EXTERNAL_BYTE_ELEMENTS: |
| 3259 __ movsxbq(rcx, Operand(rbx, rcx, times_1, 0)); | 3259 __ movsxbq(rcx, Operand(rbx, rcx, times_1, 0)); |
| 3260 break; | 3260 break; |
| 3261 case JSObject::EXTERNAL_PIXEL_ELEMENTS: | 3261 case EXTERNAL_PIXEL_ELEMENTS: |
| 3262 case JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS: | 3262 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
| 3263 __ movzxbq(rcx, Operand(rbx, rcx, times_1, 0)); | 3263 __ movzxbq(rcx, Operand(rbx, rcx, times_1, 0)); |
| 3264 break; | 3264 break; |
| 3265 case JSObject::EXTERNAL_SHORT_ELEMENTS: | 3265 case EXTERNAL_SHORT_ELEMENTS: |
| 3266 __ movsxwq(rcx, Operand(rbx, rcx, times_2, 0)); | 3266 __ movsxwq(rcx, Operand(rbx, rcx, times_2, 0)); |
| 3267 break; | 3267 break; |
| 3268 case JSObject::EXTERNAL_UNSIGNED_SHORT_ELEMENTS: | 3268 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
| 3269 __ movzxwq(rcx, Operand(rbx, rcx, times_2, 0)); | 3269 __ movzxwq(rcx, Operand(rbx, rcx, times_2, 0)); |
| 3270 break; | 3270 break; |
| 3271 case JSObject::EXTERNAL_INT_ELEMENTS: | 3271 case EXTERNAL_INT_ELEMENTS: |
| 3272 __ movsxlq(rcx, Operand(rbx, rcx, times_4, 0)); | 3272 __ movsxlq(rcx, Operand(rbx, rcx, times_4, 0)); |
| 3273 break; | 3273 break; |
| 3274 case JSObject::EXTERNAL_UNSIGNED_INT_ELEMENTS: | 3274 case EXTERNAL_UNSIGNED_INT_ELEMENTS: |
| 3275 __ movl(rcx, Operand(rbx, rcx, times_4, 0)); | 3275 __ movl(rcx, Operand(rbx, rcx, times_4, 0)); |
| 3276 break; | 3276 break; |
| 3277 case JSObject::EXTERNAL_FLOAT_ELEMENTS: | 3277 case EXTERNAL_FLOAT_ELEMENTS: |
| 3278 __ cvtss2sd(xmm0, Operand(rbx, rcx, times_4, 0)); | 3278 __ cvtss2sd(xmm0, Operand(rbx, rcx, times_4, 0)); |
| 3279 break; | 3279 break; |
| 3280 case JSObject::EXTERNAL_DOUBLE_ELEMENTS: | 3280 case EXTERNAL_DOUBLE_ELEMENTS: |
| 3281 __ movsd(xmm0, Operand(rbx, rcx, times_8, 0)); | 3281 __ movsd(xmm0, Operand(rbx, rcx, times_8, 0)); |
| 3282 break; | 3282 break; |
| 3283 default: | 3283 default: |
| 3284 UNREACHABLE(); | 3284 UNREACHABLE(); |
| 3285 break; | 3285 break; |
| 3286 } | 3286 } |
| 3287 | 3287 |
| 3288 // rax: index | 3288 // rax: index |
| 3289 // rdx: receiver | 3289 // rdx: receiver |
| 3290 // For integer array types: | 3290 // For integer array types: |
| 3291 // rcx: value | 3291 // rcx: value |
| 3292 // For floating-point array type: | 3292 // For floating-point array type: |
| 3293 // xmm0: value as double. | 3293 // xmm0: value as double. |
| 3294 | 3294 |
| 3295 ASSERT(kSmiValueSize == 32); | 3295 ASSERT(kSmiValueSize == 32); |
| 3296 if (elements_kind == JSObject::EXTERNAL_UNSIGNED_INT_ELEMENTS) { | 3296 if (elements_kind == EXTERNAL_UNSIGNED_INT_ELEMENTS) { |
| 3297 // For the UnsignedInt array type, we need to see whether | 3297 // For the UnsignedInt array type, we need to see whether |
| 3298 // the value can be represented in a Smi. If not, we need to convert | 3298 // the value can be represented in a Smi. If not, we need to convert |
| 3299 // it to a HeapNumber. | 3299 // it to a HeapNumber. |
| 3300 Label box_int; | 3300 Label box_int; |
| 3301 | 3301 |
| 3302 __ JumpIfUIntNotValidSmiValue(rcx, &box_int, Label::kNear); | 3302 __ JumpIfUIntNotValidSmiValue(rcx, &box_int, Label::kNear); |
| 3303 | 3303 |
| 3304 __ Integer32ToSmi(rax, rcx); | 3304 __ Integer32ToSmi(rax, rcx); |
| 3305 __ ret(0); | 3305 __ ret(0); |
| 3306 | 3306 |
| 3307 __ bind(&box_int); | 3307 __ bind(&box_int); |
| 3308 | 3308 |
| 3309 // Allocate a HeapNumber for the int and perform int-to-double | 3309 // Allocate a HeapNumber for the int and perform int-to-double |
| 3310 // conversion. | 3310 // conversion. |
| 3311 // The value is zero-extended since we loaded the value from memory | 3311 // The value is zero-extended since we loaded the value from memory |
| 3312 // with movl. | 3312 // with movl. |
| 3313 __ cvtqsi2sd(xmm0, rcx); | 3313 __ cvtqsi2sd(xmm0, rcx); |
| 3314 | 3314 |
| 3315 __ AllocateHeapNumber(rcx, rbx, &slow); | 3315 __ AllocateHeapNumber(rcx, rbx, &slow); |
| 3316 // Set the value. | 3316 // Set the value. |
| 3317 __ movsd(FieldOperand(rcx, HeapNumber::kValueOffset), xmm0); | 3317 __ movsd(FieldOperand(rcx, HeapNumber::kValueOffset), xmm0); |
| 3318 __ movq(rax, rcx); | 3318 __ movq(rax, rcx); |
| 3319 __ ret(0); | 3319 __ ret(0); |
| 3320 } else if (elements_kind == JSObject::EXTERNAL_FLOAT_ELEMENTS || | 3320 } else if (elements_kind == EXTERNAL_FLOAT_ELEMENTS || |
| 3321 elements_kind == JSObject::EXTERNAL_DOUBLE_ELEMENTS) { | 3321 elements_kind == EXTERNAL_DOUBLE_ELEMENTS) { |
| 3322 // For the floating-point array type, we need to always allocate a | 3322 // For the floating-point array type, we need to always allocate a |
| 3323 // HeapNumber. | 3323 // HeapNumber. |
| 3324 __ AllocateHeapNumber(rcx, rbx, &slow); | 3324 __ AllocateHeapNumber(rcx, rbx, &slow); |
| 3325 // Set the value. | 3325 // Set the value. |
| 3326 __ movsd(FieldOperand(rcx, HeapNumber::kValueOffset), xmm0); | 3326 __ movsd(FieldOperand(rcx, HeapNumber::kValueOffset), xmm0); |
| 3327 __ movq(rax, rcx); | 3327 __ movq(rax, rcx); |
| 3328 __ ret(0); | 3328 __ ret(0); |
| 3329 } else { | 3329 } else { |
| 3330 __ Integer32ToSmi(rax, rcx); | 3330 __ Integer32ToSmi(rax, rcx); |
| 3331 __ ret(0); | 3331 __ ret(0); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 3354 // -- rsp[0] : return address | 3354 // -- rsp[0] : return address |
| 3355 // ----------------------------------- | 3355 // ----------------------------------- |
| 3356 Handle<Code> miss_ic = | 3356 Handle<Code> miss_ic = |
| 3357 masm->isolate()->builtins()->KeyedLoadIC_MissForceGeneric(); | 3357 masm->isolate()->builtins()->KeyedLoadIC_MissForceGeneric(); |
| 3358 __ jmp(miss_ic, RelocInfo::CODE_TARGET); | 3358 __ jmp(miss_ic, RelocInfo::CODE_TARGET); |
| 3359 } | 3359 } |
| 3360 | 3360 |
| 3361 | 3361 |
| 3362 void KeyedStoreStubCompiler::GenerateStoreExternalArray( | 3362 void KeyedStoreStubCompiler::GenerateStoreExternalArray( |
| 3363 MacroAssembler* masm, | 3363 MacroAssembler* masm, |
| 3364 JSObject::ElementsKind elements_kind) { | 3364 ElementsKind elements_kind) { |
| 3365 // ----------- S t a t e ------------- | 3365 // ----------- S t a t e ------------- |
| 3366 // -- rax : value | 3366 // -- rax : value |
| 3367 // -- rcx : key | 3367 // -- rcx : key |
| 3368 // -- rdx : receiver | 3368 // -- rdx : receiver |
| 3369 // -- rsp[0] : return address | 3369 // -- rsp[0] : return address |
| 3370 // ----------------------------------- | 3370 // ----------------------------------- |
| 3371 Label slow, miss_force_generic; | 3371 Label slow, miss_force_generic; |
| 3372 | 3372 |
| 3373 // This stub is meant to be tail-jumped to, the receiver must already | 3373 // This stub is meant to be tail-jumped to, the receiver must already |
| 3374 // have been verified by the caller to not be a smi. | 3374 // have been verified by the caller to not be a smi. |
| 3375 | 3375 |
| 3376 // Check that the key is a smi. | 3376 // Check that the key is a smi. |
| 3377 __ JumpIfNotSmi(rcx, &miss_force_generic); | 3377 __ JumpIfNotSmi(rcx, &miss_force_generic); |
| 3378 | 3378 |
| 3379 // Check that the index is in range. | 3379 // Check that the index is in range. |
| 3380 __ movq(rbx, FieldOperand(rdx, JSObject::kElementsOffset)); | 3380 __ movq(rbx, FieldOperand(rdx, JSObject::kElementsOffset)); |
| 3381 __ SmiToInteger32(rdi, rcx); // Untag the index. | 3381 __ SmiToInteger32(rdi, rcx); // Untag the index. |
| 3382 __ cmpq(rcx, FieldOperand(rbx, ExternalArray::kLengthOffset)); | 3382 __ cmpq(rcx, FieldOperand(rbx, ExternalArray::kLengthOffset)); |
| 3383 // Unsigned comparison catches both negative and too-large values. | 3383 // Unsigned comparison catches both negative and too-large values. |
| 3384 __ j(above_equal, &miss_force_generic); | 3384 __ j(above_equal, &miss_force_generic); |
| 3385 | 3385 |
| 3386 // Handle both smis and HeapNumbers in the fast path. Go to the | 3386 // Handle both smis and HeapNumbers in the fast path. Go to the |
| 3387 // runtime for all other kinds of values. | 3387 // runtime for all other kinds of values. |
| 3388 // rax: value | 3388 // rax: value |
| 3389 // rcx: key (a smi) | 3389 // rcx: key (a smi) |
| 3390 // rdx: receiver (a JSObject) | 3390 // rdx: receiver (a JSObject) |
| 3391 // rbx: elements array | 3391 // rbx: elements array |
| 3392 // rdi: untagged key | 3392 // rdi: untagged key |
| 3393 Label check_heap_number; | 3393 Label check_heap_number; |
| 3394 if (elements_kind == JSObject::EXTERNAL_PIXEL_ELEMENTS) { | 3394 if (elements_kind == EXTERNAL_PIXEL_ELEMENTS) { |
| 3395 // Float to pixel conversion is only implemented in the runtime for now. | 3395 // Float to pixel conversion is only implemented in the runtime for now. |
| 3396 __ JumpIfNotSmi(rax, &slow); | 3396 __ JumpIfNotSmi(rax, &slow); |
| 3397 } else { | 3397 } else { |
| 3398 __ JumpIfNotSmi(rax, &check_heap_number, Label::kNear); | 3398 __ JumpIfNotSmi(rax, &check_heap_number, Label::kNear); |
| 3399 } | 3399 } |
| 3400 // No more branches to slow case on this path. Key and receiver not needed. | 3400 // No more branches to slow case on this path. Key and receiver not needed. |
| 3401 __ SmiToInteger32(rdx, rax); | 3401 __ SmiToInteger32(rdx, rax); |
| 3402 __ movq(rbx, FieldOperand(rbx, ExternalArray::kExternalPointerOffset)); | 3402 __ movq(rbx, FieldOperand(rbx, ExternalArray::kExternalPointerOffset)); |
| 3403 // rbx: base pointer of external storage | 3403 // rbx: base pointer of external storage |
| 3404 switch (elements_kind) { | 3404 switch (elements_kind) { |
| 3405 case JSObject::EXTERNAL_PIXEL_ELEMENTS: | 3405 case EXTERNAL_PIXEL_ELEMENTS: |
| 3406 { // Clamp the value to [0..255]. | 3406 { // Clamp the value to [0..255]. |
| 3407 Label done; | 3407 Label done; |
| 3408 __ testl(rdx, Immediate(0xFFFFFF00)); | 3408 __ testl(rdx, Immediate(0xFFFFFF00)); |
| 3409 __ j(zero, &done, Label::kNear); | 3409 __ j(zero, &done, Label::kNear); |
| 3410 __ setcc(negative, rdx); // 1 if negative, 0 if positive. | 3410 __ setcc(negative, rdx); // 1 if negative, 0 if positive. |
| 3411 __ decb(rdx); // 0 if negative, 255 if positive. | 3411 __ decb(rdx); // 0 if negative, 255 if positive. |
| 3412 __ bind(&done); | 3412 __ bind(&done); |
| 3413 } | 3413 } |
| 3414 __ movb(Operand(rbx, rdi, times_1, 0), rdx); | 3414 __ movb(Operand(rbx, rdi, times_1, 0), rdx); |
| 3415 break; | 3415 break; |
| 3416 case JSObject::EXTERNAL_BYTE_ELEMENTS: | 3416 case EXTERNAL_BYTE_ELEMENTS: |
| 3417 case JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS: | 3417 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
| 3418 __ movb(Operand(rbx, rdi, times_1, 0), rdx); | 3418 __ movb(Operand(rbx, rdi, times_1, 0), rdx); |
| 3419 break; | 3419 break; |
| 3420 case JSObject::EXTERNAL_SHORT_ELEMENTS: | 3420 case EXTERNAL_SHORT_ELEMENTS: |
| 3421 case JSObject::EXTERNAL_UNSIGNED_SHORT_ELEMENTS: | 3421 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
| 3422 __ movw(Operand(rbx, rdi, times_2, 0), rdx); | 3422 __ movw(Operand(rbx, rdi, times_2, 0), rdx); |
| 3423 break; | 3423 break; |
| 3424 case JSObject::EXTERNAL_INT_ELEMENTS: | 3424 case EXTERNAL_INT_ELEMENTS: |
| 3425 case JSObject::EXTERNAL_UNSIGNED_INT_ELEMENTS: | 3425 case EXTERNAL_UNSIGNED_INT_ELEMENTS: |
| 3426 __ movl(Operand(rbx, rdi, times_4, 0), rdx); | 3426 __ movl(Operand(rbx, rdi, times_4, 0), rdx); |
| 3427 break; | 3427 break; |
| 3428 case JSObject::EXTERNAL_FLOAT_ELEMENTS: | 3428 case EXTERNAL_FLOAT_ELEMENTS: |
| 3429 // Need to perform int-to-float conversion. | 3429 // Need to perform int-to-float conversion. |
| 3430 __ cvtlsi2ss(xmm0, rdx); | 3430 __ cvtlsi2ss(xmm0, rdx); |
| 3431 __ movss(Operand(rbx, rdi, times_4, 0), xmm0); | 3431 __ movss(Operand(rbx, rdi, times_4, 0), xmm0); |
| 3432 break; | 3432 break; |
| 3433 case JSObject::EXTERNAL_DOUBLE_ELEMENTS: | 3433 case EXTERNAL_DOUBLE_ELEMENTS: |
| 3434 // Need to perform int-to-float conversion. | 3434 // Need to perform int-to-float conversion. |
| 3435 __ cvtlsi2sd(xmm0, rdx); | 3435 __ cvtlsi2sd(xmm0, rdx); |
| 3436 __ movsd(Operand(rbx, rdi, times_8, 0), xmm0); | 3436 __ movsd(Operand(rbx, rdi, times_8, 0), xmm0); |
| 3437 break; | 3437 break; |
| 3438 case JSObject::FAST_ELEMENTS: | 3438 case FAST_ELEMENTS: |
| 3439 case JSObject::FAST_DOUBLE_ELEMENTS: | 3439 case FAST_DOUBLE_ELEMENTS: |
| 3440 case JSObject::DICTIONARY_ELEMENTS: | 3440 case DICTIONARY_ELEMENTS: |
| 3441 case JSObject::NON_STRICT_ARGUMENTS_ELEMENTS: | 3441 case NON_STRICT_ARGUMENTS_ELEMENTS: |
| 3442 UNREACHABLE(); | 3442 UNREACHABLE(); |
| 3443 break; | 3443 break; |
| 3444 } | 3444 } |
| 3445 __ ret(0); | 3445 __ ret(0); |
| 3446 | 3446 |
| 3447 // TODO(danno): handle heap number -> pixel array conversion | 3447 // TODO(danno): handle heap number -> pixel array conversion |
| 3448 if (elements_kind != JSObject::EXTERNAL_PIXEL_ELEMENTS) { | 3448 if (elements_kind != EXTERNAL_PIXEL_ELEMENTS) { |
| 3449 __ bind(&check_heap_number); | 3449 __ bind(&check_heap_number); |
| 3450 // rax: value | 3450 // rax: value |
| 3451 // rcx: key (a smi) | 3451 // rcx: key (a smi) |
| 3452 // rdx: receiver (a JSObject) | 3452 // rdx: receiver (a JSObject) |
| 3453 // rbx: elements array | 3453 // rbx: elements array |
| 3454 // rdi: untagged key | 3454 // rdi: untagged key |
| 3455 __ CmpObjectType(rax, HEAP_NUMBER_TYPE, kScratchRegister); | 3455 __ CmpObjectType(rax, HEAP_NUMBER_TYPE, kScratchRegister); |
| 3456 __ j(not_equal, &slow); | 3456 __ j(not_equal, &slow); |
| 3457 // No more branches to slow case on this path. | 3457 // No more branches to slow case on this path. |
| 3458 | 3458 |
| 3459 // The WebGL specification leaves the behavior of storing NaN and | 3459 // The WebGL specification leaves the behavior of storing NaN and |
| 3460 // +/-Infinity into integer arrays basically undefined. For more | 3460 // +/-Infinity into integer arrays basically undefined. For more |
| 3461 // reproducible behavior, convert these to zero. | 3461 // reproducible behavior, convert these to zero. |
| 3462 __ movsd(xmm0, FieldOperand(rax, HeapNumber::kValueOffset)); | 3462 __ movsd(xmm0, FieldOperand(rax, HeapNumber::kValueOffset)); |
| 3463 __ movq(rbx, FieldOperand(rbx, ExternalArray::kExternalPointerOffset)); | 3463 __ movq(rbx, FieldOperand(rbx, ExternalArray::kExternalPointerOffset)); |
| 3464 // rdi: untagged index | 3464 // rdi: untagged index |
| 3465 // rbx: base pointer of external storage | 3465 // rbx: base pointer of external storage |
| 3466 // top of FPU stack: value | 3466 // top of FPU stack: value |
| 3467 if (elements_kind == JSObject::EXTERNAL_FLOAT_ELEMENTS) { | 3467 if (elements_kind == EXTERNAL_FLOAT_ELEMENTS) { |
| 3468 __ cvtsd2ss(xmm0, xmm0); | 3468 __ cvtsd2ss(xmm0, xmm0); |
| 3469 __ movss(Operand(rbx, rdi, times_4, 0), xmm0); | 3469 __ movss(Operand(rbx, rdi, times_4, 0), xmm0); |
| 3470 __ ret(0); | 3470 __ ret(0); |
| 3471 } else if (elements_kind == JSObject::EXTERNAL_DOUBLE_ELEMENTS) { | 3471 } else if (elements_kind == EXTERNAL_DOUBLE_ELEMENTS) { |
| 3472 __ movsd(Operand(rbx, rdi, times_8, 0), xmm0); | 3472 __ movsd(Operand(rbx, rdi, times_8, 0), xmm0); |
| 3473 __ ret(0); | 3473 __ ret(0); |
| 3474 } else { | 3474 } else { |
| 3475 // Perform float-to-int conversion with truncation (round-to-zero) | 3475 // Perform float-to-int conversion with truncation (round-to-zero) |
| 3476 // behavior. | 3476 // behavior. |
| 3477 | 3477 |
| 3478 // Convert to int32 and store the low byte/word. | 3478 // Convert to int32 and store the low byte/word. |
| 3479 // If the value is NaN or +/-infinity, the result is 0x80000000, | 3479 // If the value is NaN or +/-infinity, the result is 0x80000000, |
| 3480 // which is automatically zero when taken mod 2^n, n < 32. | 3480 // which is automatically zero when taken mod 2^n, n < 32. |
| 3481 // rdx: value (converted to an untagged integer) | 3481 // rdx: value (converted to an untagged integer) |
| 3482 // rdi: untagged index | 3482 // rdi: untagged index |
| 3483 // rbx: base pointer of external storage | 3483 // rbx: base pointer of external storage |
| 3484 switch (elements_kind) { | 3484 switch (elements_kind) { |
| 3485 case JSObject::EXTERNAL_BYTE_ELEMENTS: | 3485 case EXTERNAL_BYTE_ELEMENTS: |
| 3486 case JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS: | 3486 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
| 3487 __ cvttsd2si(rdx, xmm0); | 3487 __ cvttsd2si(rdx, xmm0); |
| 3488 __ movb(Operand(rbx, rdi, times_1, 0), rdx); | 3488 __ movb(Operand(rbx, rdi, times_1, 0), rdx); |
| 3489 break; | 3489 break; |
| 3490 case JSObject::EXTERNAL_SHORT_ELEMENTS: | 3490 case EXTERNAL_SHORT_ELEMENTS: |
| 3491 case JSObject::EXTERNAL_UNSIGNED_SHORT_ELEMENTS: | 3491 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
| 3492 __ cvttsd2si(rdx, xmm0); | 3492 __ cvttsd2si(rdx, xmm0); |
| 3493 __ movw(Operand(rbx, rdi, times_2, 0), rdx); | 3493 __ movw(Operand(rbx, rdi, times_2, 0), rdx); |
| 3494 break; | 3494 break; |
| 3495 case JSObject::EXTERNAL_INT_ELEMENTS: | 3495 case EXTERNAL_INT_ELEMENTS: |
| 3496 case JSObject::EXTERNAL_UNSIGNED_INT_ELEMENTS: | 3496 case EXTERNAL_UNSIGNED_INT_ELEMENTS: |
| 3497 // Convert to int64, so that NaN and infinities become | 3497 // Convert to int64, so that NaN and infinities become |
| 3498 // 0x8000000000000000, which is zero mod 2^32. | 3498 // 0x8000000000000000, which is zero mod 2^32. |
| 3499 __ cvttsd2siq(rdx, xmm0); | 3499 __ cvttsd2siq(rdx, xmm0); |
| 3500 __ movl(Operand(rbx, rdi, times_4, 0), rdx); | 3500 __ movl(Operand(rbx, rdi, times_4, 0), rdx); |
| 3501 break; | 3501 break; |
| 3502 case JSObject::EXTERNAL_PIXEL_ELEMENTS: | 3502 case EXTERNAL_PIXEL_ELEMENTS: |
| 3503 case JSObject::EXTERNAL_FLOAT_ELEMENTS: | 3503 case EXTERNAL_FLOAT_ELEMENTS: |
| 3504 case JSObject::EXTERNAL_DOUBLE_ELEMENTS: | 3504 case EXTERNAL_DOUBLE_ELEMENTS: |
| 3505 case JSObject::FAST_ELEMENTS: | 3505 case FAST_ELEMENTS: |
| 3506 case JSObject::FAST_DOUBLE_ELEMENTS: | 3506 case FAST_DOUBLE_ELEMENTS: |
| 3507 case JSObject::DICTIONARY_ELEMENTS: | 3507 case DICTIONARY_ELEMENTS: |
| 3508 case JSObject::NON_STRICT_ARGUMENTS_ELEMENTS: | 3508 case NON_STRICT_ARGUMENTS_ELEMENTS: |
| 3509 UNREACHABLE(); | 3509 UNREACHABLE(); |
| 3510 break; | 3510 break; |
| 3511 } | 3511 } |
| 3512 __ ret(0); | 3512 __ ret(0); |
| 3513 } | 3513 } |
| 3514 } | 3514 } |
| 3515 | 3515 |
| 3516 // Slow case: call runtime. | 3516 // Slow case: call runtime. |
| 3517 __ bind(&slow); | 3517 __ bind(&slow); |
| 3518 | 3518 |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3767 masm->isolate()->builtins()->KeyedStoreIC_MissForceGeneric(); | 3767 masm->isolate()->builtins()->KeyedStoreIC_MissForceGeneric(); |
| 3768 __ jmp(ic_force_generic, RelocInfo::CODE_TARGET); | 3768 __ jmp(ic_force_generic, RelocInfo::CODE_TARGET); |
| 3769 } | 3769 } |
| 3770 | 3770 |
| 3771 | 3771 |
| 3772 #undef __ | 3772 #undef __ |
| 3773 | 3773 |
| 3774 } } // namespace v8::internal | 3774 } } // namespace v8::internal |
| 3775 | 3775 |
| 3776 #endif // V8_TARGET_ARCH_X64 | 3776 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |