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

Side by Side Diff: src/ia32/lithium-ia32.cc

Issue 14075014: Fixed issue in StoreNamedField codegen where integer32 constants were not converted to a smi. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Verify that integer32 constants used without a register fit in smi range Created 7 years, 8 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/ia32/lithium-codegen-ia32.cc ('k') | src/x64/lithium-codegen-x64.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 2264 matching lines...) Expand 10 before | Expand all | Expand 10 after
2275 2275
2276 if (!CpuFeatures::IsSafeForSnapshot(SSE2) && 2276 if (!CpuFeatures::IsSafeForSnapshot(SSE2) &&
2277 IsDoubleOrFloatElementsKind(elements_kind)) { 2277 IsDoubleOrFloatElementsKind(elements_kind)) {
2278 return UseRegisterAtStart(instr->value()); 2278 return UseRegisterAtStart(instr->value());
2279 } 2279 }
2280 2280
2281 return UseRegister(instr->value()); 2281 return UseRegister(instr->value());
2282 } 2282 }
2283 2283
2284 2284
2285 // DoStoreKeyed and DoStoreNamedField have special considerations for allowing
2286 // use of a constant instead of a register.
2287 static bool StoreConstantValueAllowed(HValue* value) {
2288 if (value->IsConstant()) {
2289 HConstant* constant_value = HConstant::cast(value);
2290 return constant_value->HasSmiValue()
2291 || constant_value->HasDoubleValue()
2292 || constant_value->ImmortalImmovable();
2293 }
2294 return false;
2295 }
2296
2297
2285 LInstruction* LChunkBuilder::DoStoreKeyed(HStoreKeyed* instr) { 2298 LInstruction* LChunkBuilder::DoStoreKeyed(HStoreKeyed* instr) {
2286 if (!instr->is_external()) { 2299 if (!instr->is_external()) {
2287 ASSERT(instr->elements()->representation().IsTagged()); 2300 ASSERT(instr->elements()->representation().IsTagged());
2288 ASSERT(instr->key()->representation().IsInteger32() || 2301 ASSERT(instr->key()->representation().IsInteger32() ||
2289 instr->key()->representation().IsTagged()); 2302 instr->key()->representation().IsTagged());
2290 2303
2291 if (instr->value()->representation().IsDouble()) { 2304 if (instr->value()->representation().IsDouble()) {
2292 LOperand* object = UseRegisterAtStart(instr->elements()); 2305 LOperand* object = UseRegisterAtStart(instr->elements());
2293 LOperand* val = NULL; 2306 LOperand* val = NULL;
2294 if (CpuFeatures::IsSafeForSnapshot(SSE2)) { 2307 if (CpuFeatures::IsSafeForSnapshot(SSE2)) {
2295 val = UseRegisterAtStart(instr->value()); 2308 val = UseRegisterAtStart(instr->value());
2296 } else if (!instr->IsConstantHoleStore()) { 2309 } else if (!instr->IsConstantHoleStore()) {
2297 val = UseX87TopOfStack(instr->value()); 2310 val = UseX87TopOfStack(instr->value());
2298 } 2311 }
2299 LOperand* key = UseRegisterOrConstantAtStart(instr->key()); 2312 LOperand* key = UseRegisterOrConstantAtStart(instr->key());
2300 return new(zone()) LStoreKeyed(object, key, val); 2313 return new(zone()) LStoreKeyed(object, key, val);
2301 } else { 2314 } else {
2302 ASSERT(instr->value()->representation().IsTagged()); 2315 ASSERT(instr->value()->representation().IsTagged());
2303 bool needs_write_barrier = instr->NeedsWriteBarrier(); 2316 bool needs_write_barrier = instr->NeedsWriteBarrier();
2304 2317
2305 LOperand* obj = UseRegister(instr->elements()); 2318 LOperand* obj = UseRegister(instr->elements());
2306 LOperand* val; 2319 LOperand* val;
2307 LOperand* key; 2320 LOperand* key;
2308 if (needs_write_barrier) { 2321 if (needs_write_barrier) {
2309 val = UseTempRegister(instr->value()); 2322 val = UseTempRegister(instr->value());
2310 key = UseTempRegister(instr->key()); 2323 key = UseTempRegister(instr->key());
2311 } else { 2324 } else {
2312 val = UseRegisterOrConstantAtStart(instr->value()); 2325 if (StoreConstantValueAllowed(instr->value())) {
2313 key = UseRegisterOrConstantAtStart(instr->key()); 2326 val = UseRegisterOrConstantAtStart(instr->value());
2327 } else {
2328 val = UseRegisterAtStart(instr->value());
2329 }
2330
2331 if (StoreConstantValueAllowed(instr->key())) {
2332 key = UseRegisterOrConstantAtStart(instr->key());
2333 } else {
2334 key = UseRegisterAtStart(instr->key());
2335 }
2314 } 2336 }
2315 return new(zone()) LStoreKeyed(obj, key, val); 2337 return new(zone()) LStoreKeyed(obj, key, val);
2316 } 2338 }
2317 } 2339 }
2318 2340
2319 ElementsKind elements_kind = instr->elements_kind(); 2341 ElementsKind elements_kind = instr->elements_kind();
2320 ASSERT( 2342 ASSERT(
2321 (instr->value()->representation().IsInteger32() && 2343 (instr->value()->representation().IsInteger32() &&
2322 (elements_kind != EXTERNAL_FLOAT_ELEMENTS) && 2344 (elements_kind != EXTERNAL_FLOAT_ELEMENTS) &&
2323 (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) || 2345 (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) ||
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
2404 if (needs_write_barrier) { 2426 if (needs_write_barrier) {
2405 obj = instr->is_in_object() 2427 obj = instr->is_in_object()
2406 ? UseRegister(instr->object()) 2428 ? UseRegister(instr->object())
2407 : UseTempRegister(instr->object()); 2429 : UseTempRegister(instr->object());
2408 } else { 2430 } else {
2409 obj = needs_write_barrier_for_map 2431 obj = needs_write_barrier_for_map
2410 ? UseRegister(instr->object()) 2432 ? UseRegister(instr->object())
2411 : UseRegisterAtStart(instr->object()); 2433 : UseRegisterAtStart(instr->object());
2412 } 2434 }
2413 2435
2414 bool register_or_constant = false;
2415 if (instr->value()->IsConstant()) {
2416 HConstant* constant_value = HConstant::cast(instr->value());
2417 register_or_constant = constant_value->HasInteger32Value()
2418 || constant_value->HasDoubleValue()
2419 || constant_value->ImmortalImmovable();
2420 }
2421
2422 LOperand* val; 2436 LOperand* val;
2423 if (needs_write_barrier) { 2437 if (needs_write_barrier) {
2424 val = UseTempRegister(instr->value()); 2438 val = UseTempRegister(instr->value());
2425 } else if (register_or_constant) { 2439 } else if (StoreConstantValueAllowed(instr->value())) {
2426 val = UseRegisterOrConstant(instr->value()); 2440 val = UseRegisterOrConstant(instr->value());
2427 } else { 2441 } else {
2428 val = UseRegister(instr->value()); 2442 val = UseRegister(instr->value());
2429 } 2443 }
2430 2444
2431 // We only need a scratch register if we have a write barrier or we 2445 // We only need a scratch register if we have a write barrier or we
2432 // have a store into the properties array (not in-object-property). 2446 // have a store into the properties array (not in-object-property).
2433 LOperand* temp = (!instr->is_in_object() || needs_write_barrier || 2447 LOperand* temp = (!instr->is_in_object() || needs_write_barrier ||
2434 needs_write_barrier_for_map) ? TempRegister() : NULL; 2448 needs_write_barrier_for_map) ? TempRegister() : NULL;
2435 2449
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
2753 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { 2767 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) {
2754 LOperand* object = UseRegister(instr->object()); 2768 LOperand* object = UseRegister(instr->object());
2755 LOperand* index = UseTempRegister(instr->index()); 2769 LOperand* index = UseTempRegister(instr->index());
2756 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); 2770 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index));
2757 } 2771 }
2758 2772
2759 2773
2760 } } // namespace v8::internal 2774 } } // namespace v8::internal
2761 2775
2762 #endif // V8_TARGET_ARCH_IA32 2776 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/lithium-codegen-ia32.cc ('k') | src/x64/lithium-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698