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

Side by Side Diff: src/x64/lithium-codegen-x64.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/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 2201 matching lines...) Expand 10 before | Expand all | Expand 10 after
2212 __ j(equal, &done, Label::kNear); 2212 __ j(equal, &done, Label::kNear);
2213 __ CompareRoot(FieldOperand(result, HeapObject::kMapOffset), 2213 __ CompareRoot(FieldOperand(result, HeapObject::kMapOffset),
2214 Heap::kFixedCOWArrayMapRootIndex); 2214 Heap::kFixedCOWArrayMapRootIndex);
2215 __ j(equal, &done, Label::kNear); 2215 __ j(equal, &done, Label::kNear);
2216 Register temp((result.is(rax)) ? rbx : rax); 2216 Register temp((result.is(rax)) ? rbx : rax);
2217 __ push(temp); 2217 __ push(temp);
2218 __ movq(temp, FieldOperand(result, HeapObject::kMapOffset)); 2218 __ movq(temp, FieldOperand(result, HeapObject::kMapOffset));
2219 __ movzxbq(temp, FieldOperand(temp, Map::kBitField2Offset)); 2219 __ movzxbq(temp, FieldOperand(temp, Map::kBitField2Offset));
2220 __ and_(temp, Immediate(Map::kElementsKindMask)); 2220 __ and_(temp, Immediate(Map::kElementsKindMask));
2221 __ shr(temp, Immediate(Map::kElementsKindShift)); 2221 __ shr(temp, Immediate(Map::kElementsKindShift));
2222 __ cmpl(temp, Immediate(JSObject::FAST_ELEMENTS)); 2222 __ cmpl(temp, Immediate(FAST_ELEMENTS));
2223 __ j(equal, &ok, Label::kNear); 2223 __ j(equal, &ok, Label::kNear);
2224 __ cmpl(temp, Immediate(JSObject::FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND)); 2224 __ cmpl(temp, Immediate(FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND));
2225 __ j(less, &fail, Label::kNear); 2225 __ j(less, &fail, Label::kNear);
2226 __ cmpl(temp, Immediate(JSObject::LAST_EXTERNAL_ARRAY_ELEMENTS_KIND)); 2226 __ cmpl(temp, Immediate(LAST_EXTERNAL_ARRAY_ELEMENTS_KIND));
2227 __ j(less_equal, &ok, Label::kNear); 2227 __ j(less_equal, &ok, Label::kNear);
2228 __ bind(&fail); 2228 __ bind(&fail);
2229 __ Abort("Check for fast or external elements failed"); 2229 __ Abort("Check for fast or external elements failed");
2230 __ bind(&ok); 2230 __ bind(&ok);
2231 __ pop(temp); 2231 __ pop(temp);
2232 __ bind(&done); 2232 __ bind(&done);
2233 } 2233 }
2234 } 2234 }
2235 2235
2236 2236
(...skipping 23 matching lines...) Expand all
2260 __ movq(result, Operand(arguments, length, times_pointer_size, kPointerSize)); 2260 __ movq(result, Operand(arguments, length, times_pointer_size, kPointerSize));
2261 } 2261 }
2262 2262
2263 2263
2264 void LCodeGen::DoLoadKeyedFastElement(LLoadKeyedFastElement* instr) { 2264 void LCodeGen::DoLoadKeyedFastElement(LLoadKeyedFastElement* instr) {
2265 Register result = ToRegister(instr->result()); 2265 Register result = ToRegister(instr->result());
2266 2266
2267 // Load the result. 2267 // Load the result.
2268 __ movq(result, 2268 __ movq(result,
2269 BuildFastArrayOperand(instr->elements(), instr->key(), 2269 BuildFastArrayOperand(instr->elements(), instr->key(),
2270 JSObject::FAST_ELEMENTS, 2270 FAST_ELEMENTS,
2271 FixedArray::kHeaderSize - kHeapObjectTag)); 2271 FixedArray::kHeaderSize - kHeapObjectTag));
2272 2272
2273 // Check for the hole value. 2273 // Check for the hole value.
2274 if (instr->hydrogen()->RequiresHoleCheck()) { 2274 if (instr->hydrogen()->RequiresHoleCheck()) {
2275 __ CompareRoot(result, Heap::kTheHoleValueRootIndex); 2275 __ CompareRoot(result, Heap::kTheHoleValueRootIndex);
2276 DeoptimizeIf(equal, instr->environment()); 2276 DeoptimizeIf(equal, instr->environment());
2277 } 2277 }
2278 } 2278 }
2279 2279
2280 2280
2281 void LCodeGen::DoLoadKeyedFastDoubleElement( 2281 void LCodeGen::DoLoadKeyedFastDoubleElement(
2282 LLoadKeyedFastDoubleElement* instr) { 2282 LLoadKeyedFastDoubleElement* instr) {
2283 XMMRegister result(ToDoubleRegister(instr->result())); 2283 XMMRegister result(ToDoubleRegister(instr->result()));
2284 2284
2285 if (instr->hydrogen()->RequiresHoleCheck()) { 2285 if (instr->hydrogen()->RequiresHoleCheck()) {
2286 int offset = FixedDoubleArray::kHeaderSize - kHeapObjectTag + 2286 int offset = FixedDoubleArray::kHeaderSize - kHeapObjectTag +
2287 sizeof(kHoleNanLower32); 2287 sizeof(kHoleNanLower32);
2288 Operand hole_check_operand = BuildFastArrayOperand( 2288 Operand hole_check_operand = BuildFastArrayOperand(
2289 instr->elements(), 2289 instr->elements(),
2290 instr->key(), 2290 instr->key(),
2291 JSObject::FAST_DOUBLE_ELEMENTS, 2291 FAST_DOUBLE_ELEMENTS,
2292 offset); 2292 offset);
2293 __ cmpl(hole_check_operand, Immediate(kHoleNanUpper32)); 2293 __ cmpl(hole_check_operand, Immediate(kHoleNanUpper32));
2294 DeoptimizeIf(equal, instr->environment()); 2294 DeoptimizeIf(equal, instr->environment());
2295 } 2295 }
2296 2296
2297 Operand double_load_operand = BuildFastArrayOperand( 2297 Operand double_load_operand = BuildFastArrayOperand(
2298 instr->elements(), instr->key(), JSObject::FAST_DOUBLE_ELEMENTS, 2298 instr->elements(), instr->key(), FAST_DOUBLE_ELEMENTS,
2299 FixedDoubleArray::kHeaderSize - kHeapObjectTag); 2299 FixedDoubleArray::kHeaderSize - kHeapObjectTag);
2300 __ movsd(result, double_load_operand); 2300 __ movsd(result, double_load_operand);
2301 } 2301 }
2302 2302
2303 2303
2304 Operand LCodeGen::BuildFastArrayOperand( 2304 Operand LCodeGen::BuildFastArrayOperand(
2305 LOperand* elements_pointer, 2305 LOperand* elements_pointer,
2306 LOperand* key, 2306 LOperand* key,
2307 JSObject::ElementsKind elements_kind, 2307 ElementsKind elements_kind,
2308 uint32_t offset) { 2308 uint32_t offset) {
2309 Register elements_pointer_reg = ToRegister(elements_pointer); 2309 Register elements_pointer_reg = ToRegister(elements_pointer);
2310 int shift_size = ElementsKindToShiftSize(elements_kind); 2310 int shift_size = ElementsKindToShiftSize(elements_kind);
2311 if (key->IsConstantOperand()) { 2311 if (key->IsConstantOperand()) {
2312 int constant_value = ToInteger32(LConstantOperand::cast(key)); 2312 int constant_value = ToInteger32(LConstantOperand::cast(key));
2313 if (constant_value & 0xF0000000) { 2313 if (constant_value & 0xF0000000) {
2314 Abort("array index constant value too big"); 2314 Abort("array index constant value too big");
2315 } 2315 }
2316 return Operand(elements_pointer_reg, 2316 return Operand(elements_pointer_reg,
2317 constant_value * (1 << shift_size) + offset); 2317 constant_value * (1 << shift_size) + offset);
2318 } else { 2318 } else {
2319 ScaleFactor scale_factor = static_cast<ScaleFactor>(shift_size); 2319 ScaleFactor scale_factor = static_cast<ScaleFactor>(shift_size);
2320 return Operand(elements_pointer_reg, ToRegister(key), 2320 return Operand(elements_pointer_reg, ToRegister(key),
2321 scale_factor, offset); 2321 scale_factor, offset);
2322 } 2322 }
2323 } 2323 }
2324 2324
2325 2325
2326 void LCodeGen::DoLoadKeyedSpecializedArrayElement( 2326 void LCodeGen::DoLoadKeyedSpecializedArrayElement(
2327 LLoadKeyedSpecializedArrayElement* instr) { 2327 LLoadKeyedSpecializedArrayElement* instr) {
2328 JSObject::ElementsKind elements_kind = instr->elements_kind(); 2328 ElementsKind elements_kind = instr->elements_kind();
2329 Operand operand(BuildFastArrayOperand(instr->external_pointer(), 2329 Operand operand(BuildFastArrayOperand(instr->external_pointer(),
2330 instr->key(), elements_kind, 0)); 2330 instr->key(), elements_kind, 0));
2331 if (elements_kind == JSObject::EXTERNAL_FLOAT_ELEMENTS) { 2331 if (elements_kind == EXTERNAL_FLOAT_ELEMENTS) {
2332 XMMRegister result(ToDoubleRegister(instr->result())); 2332 XMMRegister result(ToDoubleRegister(instr->result()));
2333 __ movss(result, operand); 2333 __ movss(result, operand);
2334 __ cvtss2sd(result, result); 2334 __ cvtss2sd(result, result);
2335 } else if (elements_kind == JSObject::EXTERNAL_DOUBLE_ELEMENTS) { 2335 } else if (elements_kind == EXTERNAL_DOUBLE_ELEMENTS) {
2336 __ movsd(ToDoubleRegister(instr->result()), operand); 2336 __ movsd(ToDoubleRegister(instr->result()), operand);
2337 } else { 2337 } else {
2338 Register result(ToRegister(instr->result())); 2338 Register result(ToRegister(instr->result()));
2339 switch (elements_kind) { 2339 switch (elements_kind) {
2340 case JSObject::EXTERNAL_BYTE_ELEMENTS: 2340 case EXTERNAL_BYTE_ELEMENTS:
2341 __ movsxbq(result, operand); 2341 __ movsxbq(result, operand);
2342 break; 2342 break;
2343 case JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS: 2343 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS:
2344 case JSObject::EXTERNAL_PIXEL_ELEMENTS: 2344 case EXTERNAL_PIXEL_ELEMENTS:
2345 __ movzxbq(result, operand); 2345 __ movzxbq(result, operand);
2346 break; 2346 break;
2347 case JSObject::EXTERNAL_SHORT_ELEMENTS: 2347 case EXTERNAL_SHORT_ELEMENTS:
2348 __ movsxwq(result, operand); 2348 __ movsxwq(result, operand);
2349 break; 2349 break;
2350 case JSObject::EXTERNAL_UNSIGNED_SHORT_ELEMENTS: 2350 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS:
2351 __ movzxwq(result, operand); 2351 __ movzxwq(result, operand);
2352 break; 2352 break;
2353 case JSObject::EXTERNAL_INT_ELEMENTS: 2353 case EXTERNAL_INT_ELEMENTS:
2354 __ movsxlq(result, operand); 2354 __ movsxlq(result, operand);
2355 break; 2355 break;
2356 case JSObject::EXTERNAL_UNSIGNED_INT_ELEMENTS: 2356 case EXTERNAL_UNSIGNED_INT_ELEMENTS:
2357 __ movl(result, operand); 2357 __ movl(result, operand);
2358 __ testl(result, result); 2358 __ testl(result, result);
2359 // TODO(danno): we could be more clever here, perhaps having a special 2359 // TODO(danno): we could be more clever here, perhaps having a special
2360 // version of the stub that detects if the overflow case actually 2360 // version of the stub that detects if the overflow case actually
2361 // happens, and generate code that returns a double rather than int. 2361 // happens, and generate code that returns a double rather than int.
2362 DeoptimizeIf(negative, instr->environment()); 2362 DeoptimizeIf(negative, instr->environment());
2363 break; 2363 break;
2364 case JSObject::EXTERNAL_FLOAT_ELEMENTS: 2364 case EXTERNAL_FLOAT_ELEMENTS:
2365 case JSObject::EXTERNAL_DOUBLE_ELEMENTS: 2365 case EXTERNAL_DOUBLE_ELEMENTS:
2366 case JSObject::FAST_ELEMENTS: 2366 case FAST_ELEMENTS:
2367 case JSObject::FAST_DOUBLE_ELEMENTS: 2367 case FAST_DOUBLE_ELEMENTS:
2368 case JSObject::DICTIONARY_ELEMENTS: 2368 case DICTIONARY_ELEMENTS:
2369 case JSObject::NON_STRICT_ARGUMENTS_ELEMENTS: 2369 case NON_STRICT_ARGUMENTS_ELEMENTS:
2370 UNREACHABLE(); 2370 UNREACHABLE();
2371 break; 2371 break;
2372 } 2372 }
2373 } 2373 }
2374 } 2374 }
2375 2375
2376 2376
2377 void LCodeGen::DoLoadKeyedGeneric(LLoadKeyedGeneric* instr) { 2377 void LCodeGen::DoLoadKeyedGeneric(LLoadKeyedGeneric* instr) {
2378 ASSERT(ToRegister(instr->object()).is(rdx)); 2378 ASSERT(ToRegister(instr->object()).is(rdx));
2379 ASSERT(ToRegister(instr->key()).is(rax)); 2379 ASSERT(ToRegister(instr->key()).is(rax));
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after
3054 __ Move(rcx, instr->hydrogen()->name()); 3054 __ Move(rcx, instr->hydrogen()->name());
3055 Handle<Code> ic = instr->strict_mode() 3055 Handle<Code> ic = instr->strict_mode()
3056 ? isolate()->builtins()->StoreIC_Initialize_Strict() 3056 ? isolate()->builtins()->StoreIC_Initialize_Strict()
3057 : isolate()->builtins()->StoreIC_Initialize(); 3057 : isolate()->builtins()->StoreIC_Initialize();
3058 CallCode(ic, RelocInfo::CODE_TARGET, instr); 3058 CallCode(ic, RelocInfo::CODE_TARGET, instr);
3059 } 3059 }
3060 3060
3061 3061
3062 void LCodeGen::DoStoreKeyedSpecializedArrayElement( 3062 void LCodeGen::DoStoreKeyedSpecializedArrayElement(
3063 LStoreKeyedSpecializedArrayElement* instr) { 3063 LStoreKeyedSpecializedArrayElement* instr) {
3064 JSObject::ElementsKind elements_kind = instr->elements_kind(); 3064 ElementsKind elements_kind = instr->elements_kind();
3065 Operand operand(BuildFastArrayOperand(instr->external_pointer(), 3065 Operand operand(BuildFastArrayOperand(instr->external_pointer(),
3066 instr->key(), elements_kind, 0)); 3066 instr->key(), elements_kind, 0));
3067 if (elements_kind == JSObject::EXTERNAL_FLOAT_ELEMENTS) { 3067 if (elements_kind == EXTERNAL_FLOAT_ELEMENTS) {
3068 XMMRegister value(ToDoubleRegister(instr->value())); 3068 XMMRegister value(ToDoubleRegister(instr->value()));
3069 __ cvtsd2ss(value, value); 3069 __ cvtsd2ss(value, value);
3070 __ movss(operand, value); 3070 __ movss(operand, value);
3071 } else if (elements_kind == JSObject::EXTERNAL_DOUBLE_ELEMENTS) { 3071 } else if (elements_kind == EXTERNAL_DOUBLE_ELEMENTS) {
3072 __ movsd(operand, ToDoubleRegister(instr->value())); 3072 __ movsd(operand, ToDoubleRegister(instr->value()));
3073 } else { 3073 } else {
3074 Register value(ToRegister(instr->value())); 3074 Register value(ToRegister(instr->value()));
3075 switch (elements_kind) { 3075 switch (elements_kind) {
3076 case JSObject::EXTERNAL_PIXEL_ELEMENTS: 3076 case EXTERNAL_PIXEL_ELEMENTS:
3077 case JSObject::EXTERNAL_BYTE_ELEMENTS: 3077 case EXTERNAL_BYTE_ELEMENTS:
3078 case JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS: 3078 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS:
3079 __ movb(operand, value); 3079 __ movb(operand, value);
3080 break; 3080 break;
3081 case JSObject::EXTERNAL_SHORT_ELEMENTS: 3081 case EXTERNAL_SHORT_ELEMENTS:
3082 case JSObject::EXTERNAL_UNSIGNED_SHORT_ELEMENTS: 3082 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS:
3083 __ movw(operand, value); 3083 __ movw(operand, value);
3084 break; 3084 break;
3085 case JSObject::EXTERNAL_INT_ELEMENTS: 3085 case EXTERNAL_INT_ELEMENTS:
3086 case JSObject::EXTERNAL_UNSIGNED_INT_ELEMENTS: 3086 case EXTERNAL_UNSIGNED_INT_ELEMENTS:
3087 __ movl(operand, value); 3087 __ movl(operand, value);
3088 break; 3088 break;
3089 case JSObject::EXTERNAL_FLOAT_ELEMENTS: 3089 case EXTERNAL_FLOAT_ELEMENTS:
3090 case JSObject::EXTERNAL_DOUBLE_ELEMENTS: 3090 case EXTERNAL_DOUBLE_ELEMENTS:
3091 case JSObject::FAST_ELEMENTS: 3091 case FAST_ELEMENTS:
3092 case JSObject::FAST_DOUBLE_ELEMENTS: 3092 case FAST_DOUBLE_ELEMENTS:
3093 case JSObject::DICTIONARY_ELEMENTS: 3093 case DICTIONARY_ELEMENTS:
3094 case JSObject::NON_STRICT_ARGUMENTS_ELEMENTS: 3094 case NON_STRICT_ARGUMENTS_ELEMENTS:
3095 UNREACHABLE(); 3095 UNREACHABLE();
3096 break; 3096 break;
3097 } 3097 }
3098 } 3098 }
3099 } 3099 }
3100 3100
3101 3101
3102 void LCodeGen::DoBoundsCheck(LBoundsCheck* instr) { 3102 void LCodeGen::DoBoundsCheck(LBoundsCheck* instr) {
3103 if (instr->index()->IsConstantOperand()) { 3103 if (instr->index()->IsConstantOperand()) {
3104 if (instr->length()->IsRegister()) { 3104 if (instr->length()->IsRegister()) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
3157 3157
3158 __ ucomisd(value, value); 3158 __ ucomisd(value, value);
3159 __ j(parity_odd, &have_value); // NaN. 3159 __ j(parity_odd, &have_value); // NaN.
3160 3160
3161 __ Set(kScratchRegister, BitCast<uint64_t>( 3161 __ Set(kScratchRegister, BitCast<uint64_t>(
3162 FixedDoubleArray::canonical_not_the_hole_nan_as_double())); 3162 FixedDoubleArray::canonical_not_the_hole_nan_as_double()));
3163 __ movq(value, kScratchRegister); 3163 __ movq(value, kScratchRegister);
3164 3164
3165 __ bind(&have_value); 3165 __ bind(&have_value);
3166 Operand double_store_operand = BuildFastArrayOperand( 3166 Operand double_store_operand = BuildFastArrayOperand(
3167 instr->elements(), instr->key(), JSObject::FAST_DOUBLE_ELEMENTS, 3167 instr->elements(), instr->key(), FAST_DOUBLE_ELEMENTS,
3168 FixedDoubleArray::kHeaderSize - kHeapObjectTag); 3168 FixedDoubleArray::kHeaderSize - kHeapObjectTag);
3169 __ movsd(double_store_operand, value); 3169 __ movsd(double_store_operand, value);
3170 } 3170 }
3171 3171
3172 void LCodeGen::DoStoreKeyedGeneric(LStoreKeyedGeneric* instr) { 3172 void LCodeGen::DoStoreKeyedGeneric(LStoreKeyedGeneric* instr) {
3173 ASSERT(ToRegister(instr->object()).is(rdx)); 3173 ASSERT(ToRegister(instr->object()).is(rdx));
3174 ASSERT(ToRegister(instr->key()).is(rcx)); 3174 ASSERT(ToRegister(instr->key()).is(rcx));
3175 ASSERT(ToRegister(instr->value()).is(rax)); 3175 ASSERT(ToRegister(instr->value()).is(rax));
3176 3176
3177 Handle<Code> ic = instr->strict_mode() 3177 Handle<Code> ic = instr->strict_mode()
(...skipping 969 matching lines...) Expand 10 before | Expand all | Expand 10 after
4147 RegisterEnvironmentForDeoptimization(environment); 4147 RegisterEnvironmentForDeoptimization(environment);
4148 ASSERT(osr_pc_offset_ == -1); 4148 ASSERT(osr_pc_offset_ == -1);
4149 osr_pc_offset_ = masm()->pc_offset(); 4149 osr_pc_offset_ = masm()->pc_offset();
4150 } 4150 }
4151 4151
4152 #undef __ 4152 #undef __
4153 4153
4154 } } // namespace v8::internal 4154 } } // namespace v8::internal
4155 4155
4156 #endif // V8_TARGET_ARCH_X64 4156 #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