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

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

Issue 14022011: Improvements in lithium code generation. Recognizing if some operands are constants, we can often s… (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Response to review comments from Danno out of band 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
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 2273 matching lines...) Expand 10 before | Expand all | Expand 10 after
2284 2284
2285 if (instr->value()->representation().IsDouble()) { 2285 if (instr->value()->representation().IsDouble()) {
2286 LOperand* object = UseRegisterAtStart(instr->elements()); 2286 LOperand* object = UseRegisterAtStart(instr->elements());
2287 LOperand* val = NULL; 2287 LOperand* val = NULL;
2288 if (CpuFeatures::IsSafeForSnapshot(SSE2)) { 2288 if (CpuFeatures::IsSafeForSnapshot(SSE2)) {
2289 val = UseRegisterAtStart(instr->value()); 2289 val = UseRegisterAtStart(instr->value());
2290 } else if (!instr->IsConstantHoleStore()) { 2290 } else if (!instr->IsConstantHoleStore()) {
2291 val = UseX87TopOfStack(instr->value()); 2291 val = UseX87TopOfStack(instr->value());
2292 } 2292 }
2293 LOperand* key = UseRegisterOrConstantAtStart(instr->key()); 2293 LOperand* key = UseRegisterOrConstantAtStart(instr->key());
2294
2295 return new(zone()) LStoreKeyed(object, key, val); 2294 return new(zone()) LStoreKeyed(object, key, val);
2296 } else { 2295 } else {
2297 ASSERT(instr->value()->representation().IsTagged()); 2296 ASSERT(instr->value()->representation().IsTagged());
2298 bool needs_write_barrier = instr->NeedsWriteBarrier(); 2297 bool needs_write_barrier = instr->NeedsWriteBarrier();
2299 2298
2300 LOperand* obj = UseRegister(instr->elements()); 2299 LOperand* obj = UseRegister(instr->elements());
2301 LOperand* val = needs_write_barrier 2300 LOperand* val;
2302 ? UseTempRegister(instr->value()) 2301 LOperand* key;
2303 : UseRegisterAtStart(instr->value()); 2302 if (needs_write_barrier) {
2304 LOperand* key = needs_write_barrier 2303 val = UseTempRegister(instr->value());
2305 ? UseTempRegister(instr->key()) 2304 key = UseTempRegister(instr->key());
2306 : UseRegisterOrConstantAtStart(instr->key()); 2305 } else {
2306 val = UseRegisterOrConstantAtStart(instr->value());
2307 key = UseRegisterOrConstantAtStart(instr->key());
2308 }
2307 return new(zone()) LStoreKeyed(obj, key, val); 2309 return new(zone()) LStoreKeyed(obj, key, val);
2308 } 2310 }
2309 } 2311 }
2310 2312
2311 ElementsKind elements_kind = instr->elements_kind(); 2313 ElementsKind elements_kind = instr->elements_kind();
2312 ASSERT( 2314 ASSERT(
2313 (instr->value()->representation().IsInteger32() && 2315 (instr->value()->representation().IsInteger32() &&
2314 (elements_kind != EXTERNAL_FLOAT_ELEMENTS) && 2316 (elements_kind != EXTERNAL_FLOAT_ELEMENTS) &&
2315 (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) || 2317 (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) ||
2316 (instr->value()->representation().IsDouble() && 2318 (instr->value()->representation().IsDouble() &&
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
2396 if (needs_write_barrier) { 2398 if (needs_write_barrier) {
2397 obj = instr->is_in_object() 2399 obj = instr->is_in_object()
2398 ? UseRegister(instr->object()) 2400 ? UseRegister(instr->object())
2399 : UseTempRegister(instr->object()); 2401 : UseTempRegister(instr->object());
2400 } else { 2402 } else {
2401 obj = needs_write_barrier_for_map 2403 obj = needs_write_barrier_for_map
2402 ? UseRegister(instr->object()) 2404 ? UseRegister(instr->object())
2403 : UseRegisterAtStart(instr->object()); 2405 : UseRegisterAtStart(instr->object());
2404 } 2406 }
2405 2407
2406 LOperand* val = needs_write_barrier 2408 LOperand* val = NULL;
2407 ? UseTempRegister(instr->value()) 2409 if (needs_write_barrier) {
2408 : UseRegister(instr->value()); 2410 val = UseTempRegister(instr->value());
2411 } else if (instr->value()->IsConstant()) {
2412 // If it's tagged, it might still be in new space
2413 HConstant* constant_value = HConstant::cast(instr->value());
2414 if (constant_value->HasInteger32Value() ||
2415 constant_value->HasDoubleValue() ||
2416 constant_value->ImmortalImmovable()) {
2417 val = UseRegisterOrConstant(instr->value());
2418 }
2419 }
2420
2421 if (val == NULL) {
2422 val = UseRegister(instr->value());
danno 2013/04/18 15:37:54 Can't you just move this to the else of the above
mvstanton 2013/04/19 16:53:28 I reworked this to be less awkward, I think.
2423 }
2409 2424
2410 // We only need a scratch register if we have a write barrier or we 2425 // We only need a scratch register if we have a write barrier or we
2411 // have a store into the properties array (not in-object-property). 2426 // have a store into the properties array (not in-object-property).
2412 LOperand* temp = (!instr->is_in_object() || needs_write_barrier || 2427 LOperand* temp = (!instr->is_in_object() || needs_write_barrier ||
2413 needs_write_barrier_for_map) ? TempRegister() : NULL; 2428 needs_write_barrier_for_map) ? TempRegister() : NULL;
2414 2429
2415 // We need a temporary register for write barrier of the map field. 2430 // We need a temporary register for write barrier of the map field.
2416 LOperand* temp_map = needs_write_barrier_for_map ? TempRegister() : NULL; 2431 LOperand* temp_map = needs_write_barrier_for_map ? TempRegister() : NULL;
2417 2432
2418 return new(zone()) LStoreNamedField(obj, val, temp, temp_map); 2433 return new(zone()) LStoreNamedField(obj, val, temp, temp_map);
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
2565 // There are no real uses of the arguments object. 2580 // There are no real uses of the arguments object.
2566 // arguments.length and element access are supported directly on 2581 // arguments.length and element access are supported directly on
2567 // stack arguments, and any real arguments object use causes a bailout. 2582 // stack arguments, and any real arguments object use causes a bailout.
2568 // So this value is never used. 2583 // So this value is never used.
2569 return NULL; 2584 return NULL;
2570 } 2585 }
2571 2586
2572 2587
2573 LInstruction* LChunkBuilder::DoAccessArgumentsAt(HAccessArgumentsAt* instr) { 2588 LInstruction* LChunkBuilder::DoAccessArgumentsAt(HAccessArgumentsAt* instr) {
2574 LOperand* args = UseRegister(instr->arguments()); 2589 LOperand* args = UseRegister(instr->arguments());
2575 LOperand* length = UseTempRegister(instr->length()); 2590 LOperand* length;
2576 LOperand* index = Use(instr->index()); 2591 LOperand* index;
2592 if (instr->length()->IsConstant() && instr->index()->IsConstant()) {
2593 length = UseRegisterOrConstant(instr->length());
2594 index = UseOrConstant(instr->index());
2595 } else {
2596 length = UseTempRegister(instr->length());
2597 index = Use(instr->index());
2598 }
2577 return DefineAsRegister(new(zone()) LAccessArgumentsAt(args, length, index)); 2599 return DefineAsRegister(new(zone()) LAccessArgumentsAt(args, length, index));
2578 } 2600 }
2579 2601
2580 2602
2581 LInstruction* LChunkBuilder::DoToFastProperties(HToFastProperties* instr) { 2603 LInstruction* LChunkBuilder::DoToFastProperties(HToFastProperties* instr) {
2582 LOperand* object = UseFixed(instr->value(), eax); 2604 LOperand* object = UseFixed(instr->value(), eax);
2583 LToFastProperties* result = new(zone()) LToFastProperties(object); 2605 LToFastProperties* result = new(zone()) LToFastProperties(object);
2584 return MarkAsCall(DefineFixed(result, eax), instr); 2606 return MarkAsCall(DefineFixed(result, eax), instr);
2585 } 2607 }
2586 2608
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
2724 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { 2746 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) {
2725 LOperand* object = UseRegister(instr->object()); 2747 LOperand* object = UseRegister(instr->object());
2726 LOperand* index = UseTempRegister(instr->index()); 2748 LOperand* index = UseTempRegister(instr->index());
2727 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); 2749 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index));
2728 } 2750 }
2729 2751
2730 2752
2731 } } // namespace v8::internal 2753 } } // namespace v8::internal
2732 2754
2733 #endif // V8_TARGET_ARCH_IA32 2755 #endif // V8_TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698