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

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

Issue 7112010: Plumbing changes to merge various element kind implementaions. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: review feedback Created 9 years, 6 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/x64/lithium-codegen-x64.h ('k') | src/x64/lithium-x64.h » ('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 2427 matching lines...) Expand 10 before | Expand all | Expand 10 after
2438 FixedArray::kHeaderSize)); 2438 FixedArray::kHeaderSize));
2439 2439
2440 // Check for the hole value. 2440 // Check for the hole value.
2441 if (instr->hydrogen()->RequiresHoleCheck()) { 2441 if (instr->hydrogen()->RequiresHoleCheck()) {
2442 __ CompareRoot(result, Heap::kTheHoleValueRootIndex); 2442 __ CompareRoot(result, Heap::kTheHoleValueRootIndex);
2443 DeoptimizeIf(equal, instr->environment()); 2443 DeoptimizeIf(equal, instr->environment());
2444 } 2444 }
2445 } 2445 }
2446 2446
2447 2447
2448 Operand LCodeGen::BuildExternalArrayOperand(LOperand* external_pointer, 2448 Operand LCodeGen::BuildExternalArrayOperand(
2449 LOperand* key, 2449 LOperand* external_pointer,
2450 ExternalArrayType array_type) { 2450 LOperand* key,
2451 JSObject::ElementsKind elements_kind) {
2451 Register external_pointer_reg = ToRegister(external_pointer); 2452 Register external_pointer_reg = ToRegister(external_pointer);
2452 int shift_size = ExternalArrayTypeToShiftSize(array_type); 2453 int shift_size = ElementsKindToShiftSize(elements_kind);
2453 if (key->IsConstantOperand()) { 2454 if (key->IsConstantOperand()) {
2454 int constant_value = ToInteger32(LConstantOperand::cast(key)); 2455 int constant_value = ToInteger32(LConstantOperand::cast(key));
2455 if (constant_value & 0xF0000000) { 2456 if (constant_value & 0xF0000000) {
2456 Abort("array index constant value too big"); 2457 Abort("array index constant value too big");
2457 } 2458 }
2458 return Operand(external_pointer_reg, constant_value * (1 << shift_size)); 2459 return Operand(external_pointer_reg, constant_value * (1 << shift_size));
2459 } else { 2460 } else {
2460 ScaleFactor scale_factor = static_cast<ScaleFactor>(shift_size); 2461 ScaleFactor scale_factor = static_cast<ScaleFactor>(shift_size);
2461 return Operand(external_pointer_reg, ToRegister(key), scale_factor, 0); 2462 return Operand(external_pointer_reg, ToRegister(key), scale_factor, 0);
2462 } 2463 }
2463 } 2464 }
2464 2465
2465 2466
2466 void LCodeGen::DoLoadKeyedSpecializedArrayElement( 2467 void LCodeGen::DoLoadKeyedSpecializedArrayElement(
2467 LLoadKeyedSpecializedArrayElement* instr) { 2468 LLoadKeyedSpecializedArrayElement* instr) {
2468 ExternalArrayType array_type = instr->array_type(); 2469 JSObject::ElementsKind elements_kind = instr->elements_kind();
2469 Operand operand(BuildExternalArrayOperand(instr->external_pointer(), 2470 Operand operand(BuildExternalArrayOperand(instr->external_pointer(),
2470 instr->key(), array_type)); 2471 instr->key(), elements_kind));
2471 if (array_type == kExternalFloatArray) { 2472 if (elements_kind == JSObject::EXTERNAL_FLOAT_ELEMENTS) {
2472 XMMRegister result(ToDoubleRegister(instr->result())); 2473 XMMRegister result(ToDoubleRegister(instr->result()));
2473 __ movss(result, operand); 2474 __ movss(result, operand);
2474 __ cvtss2sd(result, result); 2475 __ cvtss2sd(result, result);
2475 } else if (array_type == kExternalDoubleArray) { 2476 } else if (elements_kind == JSObject::EXTERNAL_DOUBLE_ELEMENTS) {
2476 __ movsd(ToDoubleRegister(instr->result()), operand); 2477 __ movsd(ToDoubleRegister(instr->result()), operand);
2477 } else { 2478 } else {
2478 Register result(ToRegister(instr->result())); 2479 Register result(ToRegister(instr->result()));
2479 switch (array_type) { 2480 switch (elements_kind) {
2480 case kExternalByteArray: 2481 case JSObject::EXTERNAL_BYTE_ELEMENTS:
2481 __ movsxbq(result, operand); 2482 __ movsxbq(result, operand);
2482 break; 2483 break;
2483 case kExternalUnsignedByteArray: 2484 case JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS:
2484 case kExternalPixelArray: 2485 case JSObject::EXTERNAL_PIXEL_ELEMENTS:
2485 __ movzxbq(result, operand); 2486 __ movzxbq(result, operand);
2486 break; 2487 break;
2487 case kExternalShortArray: 2488 case JSObject::EXTERNAL_SHORT_ELEMENTS:
2488 __ movsxwq(result, operand); 2489 __ movsxwq(result, operand);
2489 break; 2490 break;
2490 case kExternalUnsignedShortArray: 2491 case JSObject::EXTERNAL_UNSIGNED_SHORT_ELEMENTS:
2491 __ movzxwq(result, operand); 2492 __ movzxwq(result, operand);
2492 break; 2493 break;
2493 case kExternalIntArray: 2494 case JSObject::EXTERNAL_INT_ELEMENTS:
2494 __ movsxlq(result, operand); 2495 __ movsxlq(result, operand);
2495 break; 2496 break;
2496 case kExternalUnsignedIntArray: 2497 case JSObject::EXTERNAL_UNSIGNED_INT_ELEMENTS:
2497 __ movl(result, operand); 2498 __ movl(result, operand);
2498 __ testl(result, result); 2499 __ testl(result, result);
2499 // TODO(danno): we could be more clever here, perhaps having a special 2500 // TODO(danno): we could be more clever here, perhaps having a special
2500 // version of the stub that detects if the overflow case actually 2501 // version of the stub that detects if the overflow case actually
2501 // happens, and generate code that returns a double rather than int. 2502 // happens, and generate code that returns a double rather than int.
2502 DeoptimizeIf(negative, instr->environment()); 2503 DeoptimizeIf(negative, instr->environment());
2503 break; 2504 break;
2504 case kExternalFloatArray: 2505 case JSObject::EXTERNAL_FLOAT_ELEMENTS:
2505 case kExternalDoubleArray: 2506 case JSObject::EXTERNAL_DOUBLE_ELEMENTS:
2507 case JSObject::FAST_ELEMENTS:
2508 case JSObject::FAST_DOUBLE_ELEMENTS:
2509 case JSObject::DICTIONARY_ELEMENTS:
2506 UNREACHABLE(); 2510 UNREACHABLE();
2507 break; 2511 break;
2508 } 2512 }
2509 } 2513 }
2510 } 2514 }
2511 2515
2512 2516
2513 void LCodeGen::DoLoadKeyedGeneric(LLoadKeyedGeneric* instr) { 2517 void LCodeGen::DoLoadKeyedGeneric(LLoadKeyedGeneric* instr) {
2514 ASSERT(ToRegister(instr->object()).is(rdx)); 2518 ASSERT(ToRegister(instr->object()).is(rdx));
2515 ASSERT(ToRegister(instr->key()).is(rax)); 2519 ASSERT(ToRegister(instr->key()).is(rax));
(...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after
3182 __ Move(rcx, instr->hydrogen()->name()); 3186 __ Move(rcx, instr->hydrogen()->name());
3183 Handle<Code> ic = instr->strict_mode() 3187 Handle<Code> ic = instr->strict_mode()
3184 ? isolate()->builtins()->StoreIC_Initialize_Strict() 3188 ? isolate()->builtins()->StoreIC_Initialize_Strict()
3185 : isolate()->builtins()->StoreIC_Initialize(); 3189 : isolate()->builtins()->StoreIC_Initialize();
3186 CallCode(ic, RelocInfo::CODE_TARGET, instr); 3190 CallCode(ic, RelocInfo::CODE_TARGET, instr);
3187 } 3191 }
3188 3192
3189 3193
3190 void LCodeGen::DoStoreKeyedSpecializedArrayElement( 3194 void LCodeGen::DoStoreKeyedSpecializedArrayElement(
3191 LStoreKeyedSpecializedArrayElement* instr) { 3195 LStoreKeyedSpecializedArrayElement* instr) {
3192 ExternalArrayType array_type = instr->array_type(); 3196 JSObject::ElementsKind elements_kind = instr->elements_kind();
3193 Operand operand(BuildExternalArrayOperand(instr->external_pointer(), 3197 Operand operand(BuildExternalArrayOperand(instr->external_pointer(),
3194 instr->key(), array_type)); 3198 instr->key(), elements_kind));
3195 if (array_type == kExternalFloatArray) { 3199 if (elements_kind == JSObject::EXTERNAL_FLOAT_ELEMENTS) {
3196 XMMRegister value(ToDoubleRegister(instr->value())); 3200 XMMRegister value(ToDoubleRegister(instr->value()));
3197 __ cvtsd2ss(value, value); 3201 __ cvtsd2ss(value, value);
3198 __ movss(operand, value); 3202 __ movss(operand, value);
3199 } else if (array_type == kExternalDoubleArray) { 3203 } else if (elements_kind == JSObject::EXTERNAL_DOUBLE_ELEMENTS) {
3200 __ movsd(operand, ToDoubleRegister(instr->value())); 3204 __ movsd(operand, ToDoubleRegister(instr->value()));
3201 } else { 3205 } else {
3202 Register value(ToRegister(instr->value())); 3206 Register value(ToRegister(instr->value()));
3203 switch (array_type) { 3207 switch (elements_kind) {
3204 case kExternalPixelArray: 3208 case JSObject::EXTERNAL_PIXEL_ELEMENTS:
3205 case kExternalByteArray: 3209 case JSObject::EXTERNAL_BYTE_ELEMENTS:
3206 case kExternalUnsignedByteArray: 3210 case JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS:
3207 __ movb(operand, value); 3211 __ movb(operand, value);
3208 break; 3212 break;
3209 case kExternalShortArray: 3213 case JSObject::EXTERNAL_SHORT_ELEMENTS:
3210 case kExternalUnsignedShortArray: 3214 case JSObject::EXTERNAL_UNSIGNED_SHORT_ELEMENTS:
3211 __ movw(operand, value); 3215 __ movw(operand, value);
3212 break; 3216 break;
3213 case kExternalIntArray: 3217 case JSObject::EXTERNAL_INT_ELEMENTS:
3214 case kExternalUnsignedIntArray: 3218 case JSObject::EXTERNAL_UNSIGNED_INT_ELEMENTS:
3215 __ movl(operand, value); 3219 __ movl(operand, value);
3216 break; 3220 break;
3217 case kExternalFloatArray: 3221 case JSObject::EXTERNAL_FLOAT_ELEMENTS:
3218 case kExternalDoubleArray: 3222 case JSObject::EXTERNAL_DOUBLE_ELEMENTS:
3223 case JSObject::FAST_ELEMENTS:
3224 case JSObject::FAST_DOUBLE_ELEMENTS:
3225 case JSObject::DICTIONARY_ELEMENTS:
3219 UNREACHABLE(); 3226 UNREACHABLE();
3220 break; 3227 break;
3221 } 3228 }
3222 } 3229 }
3223 } 3230 }
3224 3231
3225 3232
3226 void LCodeGen::DoBoundsCheck(LBoundsCheck* instr) { 3233 void LCodeGen::DoBoundsCheck(LBoundsCheck* instr) {
3227 if (instr->length()->IsRegister()) { 3234 if (instr->length()->IsRegister()) {
3228 __ cmpq(ToRegister(instr->index()), ToRegister(instr->length())); 3235 __ cmpq(ToRegister(instr->index()), ToRegister(instr->length()));
(...skipping 1024 matching lines...) Expand 10 before | Expand all | Expand 10 after
4253 RegisterEnvironmentForDeoptimization(environment); 4260 RegisterEnvironmentForDeoptimization(environment);
4254 ASSERT(osr_pc_offset_ == -1); 4261 ASSERT(osr_pc_offset_ == -1);
4255 osr_pc_offset_ = masm()->pc_offset(); 4262 osr_pc_offset_ = masm()->pc_offset();
4256 } 4263 }
4257 4264
4258 #undef __ 4265 #undef __
4259 4266
4260 } } // namespace v8::internal 4267 } } // namespace v8::internal
4261 4268
4262 #endif // V8_TARGET_ARCH_X64 4269 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/lithium-codegen-x64.h ('k') | src/x64/lithium-x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698