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

Side by Side Diff: src/arm/lithium-codegen-arm.cc

Issue 7849017: Mechanical refactor to move ElementsKind type out of JSObject. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: latest changes Created 9 years, 3 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 | « src/arm/lithium-arm.cc ('k') | src/arm/macro-assembler-arm.cc » ('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 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 2392 matching lines...) Expand 10 before | Expand all | Expand 10 after
2403 __ LoadRoot(ip, Heap::kFixedArrayMapRootIndex); 2403 __ LoadRoot(ip, Heap::kFixedArrayMapRootIndex);
2404 __ cmp(scratch, ip); 2404 __ cmp(scratch, ip);
2405 __ b(eq, &done); 2405 __ b(eq, &done);
2406 __ LoadRoot(ip, Heap::kFixedCOWArrayMapRootIndex); 2406 __ LoadRoot(ip, Heap::kFixedCOWArrayMapRootIndex);
2407 __ cmp(scratch, ip); 2407 __ cmp(scratch, ip);
2408 __ b(eq, &done); 2408 __ b(eq, &done);
2409 // |scratch| still contains |input|'s map. 2409 // |scratch| still contains |input|'s map.
2410 __ ldr(scratch, FieldMemOperand(scratch, Map::kBitField2Offset)); 2410 __ ldr(scratch, FieldMemOperand(scratch, Map::kBitField2Offset));
2411 __ ubfx(scratch, scratch, Map::kElementsKindShift, 2411 __ ubfx(scratch, scratch, Map::kElementsKindShift,
2412 Map::kElementsKindBitCount); 2412 Map::kElementsKindBitCount);
2413 __ cmp(scratch, Operand(JSObject::FAST_ELEMENTS)); 2413 __ cmp(scratch, Operand(FAST_ELEMENTS));
2414 __ b(eq, &done); 2414 __ b(eq, &done);
2415 __ cmp(scratch, Operand(JSObject::FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND)); 2415 __ cmp(scratch, Operand(FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND));
2416 __ b(lt, &fail); 2416 __ b(lt, &fail);
2417 __ cmp(scratch, Operand(JSObject::LAST_EXTERNAL_ARRAY_ELEMENTS_KIND)); 2417 __ cmp(scratch, Operand(LAST_EXTERNAL_ARRAY_ELEMENTS_KIND));
2418 __ b(le, &done); 2418 __ b(le, &done);
2419 __ bind(&fail); 2419 __ bind(&fail);
2420 __ Abort("Check for fast or external elements failed."); 2420 __ Abort("Check for fast or external elements failed.");
2421 __ bind(&done); 2421 __ bind(&done);
2422 } 2422 }
2423 } 2423 }
2424 2424
2425 2425
2426 void LCodeGen::DoLoadExternalArrayPointer( 2426 void LCodeGen::DoLoadExternalArrayPointer(
2427 LLoadExternalArrayPointer* instr) { 2427 LLoadExternalArrayPointer* instr) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
2471 2471
2472 void LCodeGen::DoLoadKeyedFastDoubleElement( 2472 void LCodeGen::DoLoadKeyedFastDoubleElement(
2473 LLoadKeyedFastDoubleElement* instr) { 2473 LLoadKeyedFastDoubleElement* instr) {
2474 Register elements = ToRegister(instr->elements()); 2474 Register elements = ToRegister(instr->elements());
2475 bool key_is_constant = instr->key()->IsConstantOperand(); 2475 bool key_is_constant = instr->key()->IsConstantOperand();
2476 Register key = no_reg; 2476 Register key = no_reg;
2477 DwVfpRegister result = ToDoubleRegister(instr->result()); 2477 DwVfpRegister result = ToDoubleRegister(instr->result());
2478 Register scratch = scratch0(); 2478 Register scratch = scratch0();
2479 2479
2480 int shift_size = 2480 int shift_size =
2481 ElementsKindToShiftSize(JSObject::FAST_DOUBLE_ELEMENTS); 2481 ElementsKindToShiftSize(FAST_DOUBLE_ELEMENTS);
2482 int constant_key = 0; 2482 int constant_key = 0;
2483 if (key_is_constant) { 2483 if (key_is_constant) {
2484 constant_key = ToInteger32(LConstantOperand::cast(instr->key())); 2484 constant_key = ToInteger32(LConstantOperand::cast(instr->key()));
2485 if (constant_key & 0xF0000000) { 2485 if (constant_key & 0xF0000000) {
2486 Abort("array index constant value too big."); 2486 Abort("array index constant value too big.");
2487 } 2487 }
2488 } else { 2488 } else {
2489 key = ToRegister(instr->key()); 2489 key = ToRegister(instr->key());
2490 } 2490 }
2491 2491
(...skipping 16 matching lines...) Expand all
2508 } 2508 }
2509 2509
2510 __ vldr(result, elements, 0); 2510 __ vldr(result, elements, 0);
2511 } 2511 }
2512 2512
2513 2513
2514 void LCodeGen::DoLoadKeyedSpecializedArrayElement( 2514 void LCodeGen::DoLoadKeyedSpecializedArrayElement(
2515 LLoadKeyedSpecializedArrayElement* instr) { 2515 LLoadKeyedSpecializedArrayElement* instr) {
2516 Register external_pointer = ToRegister(instr->external_pointer()); 2516 Register external_pointer = ToRegister(instr->external_pointer());
2517 Register key = no_reg; 2517 Register key = no_reg;
2518 JSObject::ElementsKind elements_kind = instr->elements_kind(); 2518 ElementsKind elements_kind = instr->elements_kind();
2519 bool key_is_constant = instr->key()->IsConstantOperand(); 2519 bool key_is_constant = instr->key()->IsConstantOperand();
2520 int constant_key = 0; 2520 int constant_key = 0;
2521 if (key_is_constant) { 2521 if (key_is_constant) {
2522 constant_key = ToInteger32(LConstantOperand::cast(instr->key())); 2522 constant_key = ToInteger32(LConstantOperand::cast(instr->key()));
2523 if (constant_key & 0xF0000000) { 2523 if (constant_key & 0xF0000000) {
2524 Abort("array index constant value too big."); 2524 Abort("array index constant value too big.");
2525 } 2525 }
2526 } else { 2526 } else {
2527 key = ToRegister(instr->key()); 2527 key = ToRegister(instr->key());
2528 } 2528 }
2529 int shift_size = ElementsKindToShiftSize(elements_kind); 2529 int shift_size = ElementsKindToShiftSize(elements_kind);
2530 2530
2531 if (elements_kind == JSObject::EXTERNAL_FLOAT_ELEMENTS || 2531 if (elements_kind == EXTERNAL_FLOAT_ELEMENTS ||
2532 elements_kind == JSObject::EXTERNAL_DOUBLE_ELEMENTS) { 2532 elements_kind == EXTERNAL_DOUBLE_ELEMENTS) {
2533 CpuFeatures::Scope scope(VFP3); 2533 CpuFeatures::Scope scope(VFP3);
2534 DwVfpRegister result = ToDoubleRegister(instr->result()); 2534 DwVfpRegister result = ToDoubleRegister(instr->result());
2535 Operand operand = key_is_constant 2535 Operand operand = key_is_constant
2536 ? Operand(constant_key * (1 << shift_size)) 2536 ? Operand(constant_key * (1 << shift_size))
2537 : Operand(key, LSL, shift_size); 2537 : Operand(key, LSL, shift_size);
2538 __ add(scratch0(), external_pointer, operand); 2538 __ add(scratch0(), external_pointer, operand);
2539 if (elements_kind == JSObject::EXTERNAL_FLOAT_ELEMENTS) { 2539 if (elements_kind == EXTERNAL_FLOAT_ELEMENTS) {
2540 __ vldr(result.low(), scratch0(), 0); 2540 __ vldr(result.low(), scratch0(), 0);
2541 __ vcvt_f64_f32(result, result.low()); 2541 __ vcvt_f64_f32(result, result.low());
2542 } else { // i.e. elements_kind == JSObject::EXTERNAL_DOUBLE_ELEMENTS 2542 } else { // i.e. elements_kind == EXTERNAL_DOUBLE_ELEMENTS
2543 __ vldr(result, scratch0(), 0); 2543 __ vldr(result, scratch0(), 0);
2544 } 2544 }
2545 } else { 2545 } else {
2546 Register result = ToRegister(instr->result()); 2546 Register result = ToRegister(instr->result());
2547 MemOperand mem_operand(key_is_constant 2547 MemOperand mem_operand(key_is_constant
2548 ? MemOperand(external_pointer, constant_key * (1 << shift_size)) 2548 ? MemOperand(external_pointer, constant_key * (1 << shift_size))
2549 : MemOperand(external_pointer, key, LSL, shift_size)); 2549 : MemOperand(external_pointer, key, LSL, shift_size));
2550 switch (elements_kind) { 2550 switch (elements_kind) {
2551 case JSObject::EXTERNAL_BYTE_ELEMENTS: 2551 case EXTERNAL_BYTE_ELEMENTS:
2552 __ ldrsb(result, mem_operand); 2552 __ ldrsb(result, mem_operand);
2553 break; 2553 break;
2554 case JSObject::EXTERNAL_PIXEL_ELEMENTS: 2554 case EXTERNAL_PIXEL_ELEMENTS:
2555 case JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS: 2555 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS:
2556 __ ldrb(result, mem_operand); 2556 __ ldrb(result, mem_operand);
2557 break; 2557 break;
2558 case JSObject::EXTERNAL_SHORT_ELEMENTS: 2558 case EXTERNAL_SHORT_ELEMENTS:
2559 __ ldrsh(result, mem_operand); 2559 __ ldrsh(result, mem_operand);
2560 break; 2560 break;
2561 case JSObject::EXTERNAL_UNSIGNED_SHORT_ELEMENTS: 2561 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS:
2562 __ ldrh(result, mem_operand); 2562 __ ldrh(result, mem_operand);
2563 break; 2563 break;
2564 case JSObject::EXTERNAL_INT_ELEMENTS: 2564 case EXTERNAL_INT_ELEMENTS:
2565 __ ldr(result, mem_operand); 2565 __ ldr(result, mem_operand);
2566 break; 2566 break;
2567 case JSObject::EXTERNAL_UNSIGNED_INT_ELEMENTS: 2567 case EXTERNAL_UNSIGNED_INT_ELEMENTS:
2568 __ ldr(result, mem_operand); 2568 __ ldr(result, mem_operand);
2569 __ cmp(result, Operand(0x80000000)); 2569 __ cmp(result, Operand(0x80000000));
2570 // TODO(danno): we could be more clever here, perhaps having a special 2570 // TODO(danno): we could be more clever here, perhaps having a special
2571 // version of the stub that detects if the overflow case actually 2571 // version of the stub that detects if the overflow case actually
2572 // happens, and generate code that returns a double rather than int. 2572 // happens, and generate code that returns a double rather than int.
2573 DeoptimizeIf(cs, instr->environment()); 2573 DeoptimizeIf(cs, instr->environment());
2574 break; 2574 break;
2575 case JSObject::EXTERNAL_FLOAT_ELEMENTS: 2575 case EXTERNAL_FLOAT_ELEMENTS:
2576 case JSObject::EXTERNAL_DOUBLE_ELEMENTS: 2576 case EXTERNAL_DOUBLE_ELEMENTS:
2577 case JSObject::FAST_DOUBLE_ELEMENTS: 2577 case FAST_DOUBLE_ELEMENTS:
2578 case JSObject::FAST_ELEMENTS: 2578 case FAST_ELEMENTS:
2579 case JSObject::DICTIONARY_ELEMENTS: 2579 case DICTIONARY_ELEMENTS:
2580 case JSObject::NON_STRICT_ARGUMENTS_ELEMENTS: 2580 case NON_STRICT_ARGUMENTS_ELEMENTS:
2581 UNREACHABLE(); 2581 UNREACHABLE();
2582 break; 2582 break;
2583 } 2583 }
2584 } 2584 }
2585 } 2585 }
2586 2586
2587 2587
2588 void LCodeGen::DoLoadKeyedGeneric(LLoadKeyedGeneric* instr) { 2588 void LCodeGen::DoLoadKeyedGeneric(LLoadKeyedGeneric* instr) {
2589 ASSERT(ToRegister(instr->object()).is(r1)); 2589 ASSERT(ToRegister(instr->object()).is(r1));
2590 ASSERT(ToRegister(instr->key()).is(r0)); 2590 ASSERT(ToRegister(instr->key()).is(r0));
(...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after
3333 // Calculate the effective address of the slot in the array to store the 3333 // Calculate the effective address of the slot in the array to store the
3334 // double value. 3334 // double value.
3335 if (key_is_constant) { 3335 if (key_is_constant) {
3336 constant_key = ToInteger32(LConstantOperand::cast(instr->key())); 3336 constant_key = ToInteger32(LConstantOperand::cast(instr->key()));
3337 if (constant_key & 0xF0000000) { 3337 if (constant_key & 0xF0000000) {
3338 Abort("array index constant value too big."); 3338 Abort("array index constant value too big.");
3339 } 3339 }
3340 } else { 3340 } else {
3341 key = ToRegister(instr->key()); 3341 key = ToRegister(instr->key());
3342 } 3342 }
3343 int shift_size = ElementsKindToShiftSize(JSObject::FAST_DOUBLE_ELEMENTS); 3343 int shift_size = ElementsKindToShiftSize(FAST_DOUBLE_ELEMENTS);
3344 Operand operand = key_is_constant 3344 Operand operand = key_is_constant
3345 ? Operand(constant_key * (1 << shift_size) + 3345 ? Operand(constant_key * (1 << shift_size) +
3346 FixedDoubleArray::kHeaderSize - kHeapObjectTag) 3346 FixedDoubleArray::kHeaderSize - kHeapObjectTag)
3347 : Operand(key, LSL, shift_size); 3347 : Operand(key, LSL, shift_size);
3348 __ add(scratch, elements, operand); 3348 __ add(scratch, elements, operand);
3349 if (!key_is_constant) { 3349 if (!key_is_constant) {
3350 __ add(scratch, scratch, 3350 __ add(scratch, scratch,
3351 Operand(FixedDoubleArray::kHeaderSize - kHeapObjectTag)); 3351 Operand(FixedDoubleArray::kHeaderSize - kHeapObjectTag));
3352 } 3352 }
3353 3353
3354 // Check for NaN. All NaNs must be canonicalized. 3354 // Check for NaN. All NaNs must be canonicalized.
3355 __ VFPCompareAndSetFlags(value, value); 3355 __ VFPCompareAndSetFlags(value, value);
3356 3356
3357 // Only load canonical NaN if the comparison above set the overflow. 3357 // Only load canonical NaN if the comparison above set the overflow.
3358 __ Vmov(value, FixedDoubleArray::canonical_not_the_hole_nan_as_double(), vs); 3358 __ Vmov(value, FixedDoubleArray::canonical_not_the_hole_nan_as_double(), vs);
3359 3359
3360 __ bind(&not_nan); 3360 __ bind(&not_nan);
3361 __ vstr(value, scratch, 0); 3361 __ vstr(value, scratch, 0);
3362 } 3362 }
3363 3363
3364 3364
3365 void LCodeGen::DoStoreKeyedSpecializedArrayElement( 3365 void LCodeGen::DoStoreKeyedSpecializedArrayElement(
3366 LStoreKeyedSpecializedArrayElement* instr) { 3366 LStoreKeyedSpecializedArrayElement* instr) {
3367 3367
3368 Register external_pointer = ToRegister(instr->external_pointer()); 3368 Register external_pointer = ToRegister(instr->external_pointer());
3369 Register key = no_reg; 3369 Register key = no_reg;
3370 JSObject::ElementsKind elements_kind = instr->elements_kind(); 3370 ElementsKind elements_kind = instr->elements_kind();
3371 bool key_is_constant = instr->key()->IsConstantOperand(); 3371 bool key_is_constant = instr->key()->IsConstantOperand();
3372 int constant_key = 0; 3372 int constant_key = 0;
3373 if (key_is_constant) { 3373 if (key_is_constant) {
3374 constant_key = ToInteger32(LConstantOperand::cast(instr->key())); 3374 constant_key = ToInteger32(LConstantOperand::cast(instr->key()));
3375 if (constant_key & 0xF0000000) { 3375 if (constant_key & 0xF0000000) {
3376 Abort("array index constant value too big."); 3376 Abort("array index constant value too big.");
3377 } 3377 }
3378 } else { 3378 } else {
3379 key = ToRegister(instr->key()); 3379 key = ToRegister(instr->key());
3380 } 3380 }
3381 int shift_size = ElementsKindToShiftSize(elements_kind); 3381 int shift_size = ElementsKindToShiftSize(elements_kind);
3382 3382
3383 if (elements_kind == JSObject::EXTERNAL_FLOAT_ELEMENTS || 3383 if (elements_kind == EXTERNAL_FLOAT_ELEMENTS ||
3384 elements_kind == JSObject::EXTERNAL_DOUBLE_ELEMENTS) { 3384 elements_kind == EXTERNAL_DOUBLE_ELEMENTS) {
3385 CpuFeatures::Scope scope(VFP3); 3385 CpuFeatures::Scope scope(VFP3);
3386 DwVfpRegister value(ToDoubleRegister(instr->value())); 3386 DwVfpRegister value(ToDoubleRegister(instr->value()));
3387 Operand operand(key_is_constant ? Operand(constant_key * (1 << shift_size)) 3387 Operand operand(key_is_constant ? Operand(constant_key * (1 << shift_size))
3388 : Operand(key, LSL, shift_size)); 3388 : Operand(key, LSL, shift_size));
3389 __ add(scratch0(), external_pointer, operand); 3389 __ add(scratch0(), external_pointer, operand);
3390 if (elements_kind == JSObject::EXTERNAL_FLOAT_ELEMENTS) { 3390 if (elements_kind == EXTERNAL_FLOAT_ELEMENTS) {
3391 __ vcvt_f32_f64(double_scratch0().low(), value); 3391 __ vcvt_f32_f64(double_scratch0().low(), value);
3392 __ vstr(double_scratch0().low(), scratch0(), 0); 3392 __ vstr(double_scratch0().low(), scratch0(), 0);
3393 } else { // i.e. elements_kind == JSObject::EXTERNAL_DOUBLE_ELEMENTS 3393 } else { // i.e. elements_kind == EXTERNAL_DOUBLE_ELEMENTS
3394 __ vstr(value, scratch0(), 0); 3394 __ vstr(value, scratch0(), 0);
3395 } 3395 }
3396 } else { 3396 } else {
3397 Register value(ToRegister(instr->value())); 3397 Register value(ToRegister(instr->value()));
3398 MemOperand mem_operand(key_is_constant 3398 MemOperand mem_operand(key_is_constant
3399 ? MemOperand(external_pointer, constant_key * (1 << shift_size)) 3399 ? MemOperand(external_pointer, constant_key * (1 << shift_size))
3400 : MemOperand(external_pointer, key, LSL, shift_size)); 3400 : MemOperand(external_pointer, key, LSL, shift_size));
3401 switch (elements_kind) { 3401 switch (elements_kind) {
3402 case JSObject::EXTERNAL_PIXEL_ELEMENTS: 3402 case EXTERNAL_PIXEL_ELEMENTS:
3403 case JSObject::EXTERNAL_BYTE_ELEMENTS: 3403 case EXTERNAL_BYTE_ELEMENTS:
3404 case JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS: 3404 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS:
3405 __ strb(value, mem_operand); 3405 __ strb(value, mem_operand);
3406 break; 3406 break;
3407 case JSObject::EXTERNAL_SHORT_ELEMENTS: 3407 case EXTERNAL_SHORT_ELEMENTS:
3408 case JSObject::EXTERNAL_UNSIGNED_SHORT_ELEMENTS: 3408 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS:
3409 __ strh(value, mem_operand); 3409 __ strh(value, mem_operand);
3410 break; 3410 break;
3411 case JSObject::EXTERNAL_INT_ELEMENTS: 3411 case EXTERNAL_INT_ELEMENTS:
3412 case JSObject::EXTERNAL_UNSIGNED_INT_ELEMENTS: 3412 case EXTERNAL_UNSIGNED_INT_ELEMENTS:
3413 __ str(value, mem_operand); 3413 __ str(value, mem_operand);
3414 break; 3414 break;
3415 case JSObject::EXTERNAL_FLOAT_ELEMENTS: 3415 case EXTERNAL_FLOAT_ELEMENTS:
3416 case JSObject::EXTERNAL_DOUBLE_ELEMENTS: 3416 case EXTERNAL_DOUBLE_ELEMENTS:
3417 case JSObject::FAST_DOUBLE_ELEMENTS: 3417 case FAST_DOUBLE_ELEMENTS:
3418 case JSObject::FAST_ELEMENTS: 3418 case FAST_ELEMENTS:
3419 case JSObject::DICTIONARY_ELEMENTS: 3419 case DICTIONARY_ELEMENTS:
3420 case JSObject::NON_STRICT_ARGUMENTS_ELEMENTS: 3420 case NON_STRICT_ARGUMENTS_ELEMENTS:
3421 UNREACHABLE(); 3421 UNREACHABLE();
3422 break; 3422 break;
3423 } 3423 }
3424 } 3424 }
3425 } 3425 }
3426 3426
3427 3427
3428 void LCodeGen::DoStoreKeyedGeneric(LStoreKeyedGeneric* instr) { 3428 void LCodeGen::DoStoreKeyedGeneric(LStoreKeyedGeneric* instr) {
3429 ASSERT(ToRegister(instr->object()).is(r2)); 3429 ASSERT(ToRegister(instr->object()).is(r2));
3430 ASSERT(ToRegister(instr->key()).is(r1)); 3430 ASSERT(ToRegister(instr->key()).is(r1));
(...skipping 1078 matching lines...) Expand 10 before | Expand all | Expand 10 after
4509 ASSERT(osr_pc_offset_ == -1); 4509 ASSERT(osr_pc_offset_ == -1);
4510 osr_pc_offset_ = masm()->pc_offset(); 4510 osr_pc_offset_ = masm()->pc_offset();
4511 } 4511 }
4512 4512
4513 4513
4514 4514
4515 4515
4516 #undef __ 4516 #undef __
4517 4517
4518 } } // namespace v8::internal 4518 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arm/lithium-arm.cc ('k') | src/arm/macro-assembler-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698