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

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

Issue 16026023: Avoid Unnecessary Smi Checks (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 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
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 1594 matching lines...) Expand 10 before | Expand all | Expand 10 after
1605 __ and_(result, Immediate(Map::kElementsKindMask)); 1605 __ and_(result, Immediate(Map::kElementsKindMask));
1606 __ shr(result, Immediate(Map::kElementsKindShift)); 1606 __ shr(result, Immediate(Map::kElementsKindShift));
1607 } 1607 }
1608 1608
1609 1609
1610 void LCodeGen::DoValueOf(LValueOf* instr) { 1610 void LCodeGen::DoValueOf(LValueOf* instr) {
1611 Register input = ToRegister(instr->value()); 1611 Register input = ToRegister(instr->value());
1612 Register result = ToRegister(instr->result()); 1612 Register result = ToRegister(instr->result());
1613 ASSERT(input.is(result)); 1613 ASSERT(input.is(result));
1614 Label done; 1614 Label done;
1615 // If the object is a smi return the object. 1615
1616 __ JumpIfSmi(input, &done, Label::kNear); 1616 if (!instr->hydrogen()->value()->IsHeapObject()) {
1617 // If the object is a smi return the object.
1618 __ JumpIfSmi(input, &done, Label::kNear);
1619 }
1617 1620
1618 // If the object is not a value type, return the object. 1621 // If the object is not a value type, return the object.
1619 __ CmpObjectType(input, JS_VALUE_TYPE, kScratchRegister); 1622 __ CmpObjectType(input, JS_VALUE_TYPE, kScratchRegister);
1620 __ j(not_equal, &done, Label::kNear); 1623 __ j(not_equal, &done, Label::kNear);
1621 __ movq(result, FieldOperand(input, JSValue::kValueOffset)); 1624 __ movq(result, FieldOperand(input, JSValue::kValueOffset));
1622 1625
1623 __ bind(&done); 1626 __ bind(&done);
1624 } 1627 }
1625 1628
1626 1629
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
2169 Label* false_label = chunk_->GetAssemblyLabel(false_block); 2172 Label* false_label = chunk_->GetAssemblyLabel(false_block);
2170 2173
2171 Condition true_cond = EmitIsObject(reg, false_label, true_label); 2174 Condition true_cond = EmitIsObject(reg, false_label, true_label);
2172 2175
2173 EmitBranch(true_block, false_block, true_cond); 2176 EmitBranch(true_block, false_block, true_cond);
2174 } 2177 }
2175 2178
2176 2179
2177 Condition LCodeGen::EmitIsString(Register input, 2180 Condition LCodeGen::EmitIsString(Register input,
2178 Register temp1, 2181 Register temp1,
2179 Label* is_not_string) { 2182 Label* is_not_string,
2180 __ JumpIfSmi(input, is_not_string); 2183 SmiCheck check_needed = INLINE_SMI_CHECK) {
2184 if (check_needed == INLINE_SMI_CHECK) {
2185 __ JumpIfSmi(input, is_not_string);
2186 }
2187
2181 Condition cond = masm_->IsObjectStringType(input, temp1, temp1); 2188 Condition cond = masm_->IsObjectStringType(input, temp1, temp1);
2182 2189
2183 return cond; 2190 return cond;
2184 } 2191 }
2185 2192
2186 2193
2187 void LCodeGen::DoIsStringAndBranch(LIsStringAndBranch* instr) { 2194 void LCodeGen::DoIsStringAndBranch(LIsStringAndBranch* instr) {
2188 Register reg = ToRegister(instr->value()); 2195 Register reg = ToRegister(instr->value());
2189 Register temp = ToRegister(instr->temp()); 2196 Register temp = ToRegister(instr->temp());
2190 2197
2191 int true_block = chunk_->LookupDestination(instr->true_block_id()); 2198 int true_block = chunk_->LookupDestination(instr->true_block_id());
2192 int false_block = chunk_->LookupDestination(instr->false_block_id()); 2199 int false_block = chunk_->LookupDestination(instr->false_block_id());
2193 Label* false_label = chunk_->GetAssemblyLabel(false_block); 2200 Label* false_label = chunk_->GetAssemblyLabel(false_block);
2194 2201
2195 Condition true_cond = EmitIsString(reg, temp, false_label); 2202 SmiCheck check_needed =
2203 instr->hydrogen()->value()->IsHeapObject()
2204 ? OMIT_SMI_CHECK : INLINE_SMI_CHECK;
2205
2206 Condition true_cond = EmitIsString(reg, temp, false_label, check_needed);
2196 2207
2197 EmitBranch(true_block, false_block, true_cond); 2208 EmitBranch(true_block, false_block, true_cond);
2198 } 2209 }
2199 2210
2200 2211
2201 void LCodeGen::DoIsSmiAndBranch(LIsSmiAndBranch* instr) { 2212 void LCodeGen::DoIsSmiAndBranch(LIsSmiAndBranch* instr) {
2202 int true_block = chunk_->LookupDestination(instr->true_block_id()); 2213 int true_block = chunk_->LookupDestination(instr->true_block_id());
2203 int false_block = chunk_->LookupDestination(instr->false_block_id()); 2214 int false_block = chunk_->LookupDestination(instr->false_block_id());
2204 2215
2205 Condition is_smi; 2216 Condition is_smi;
2206 if (instr->value()->IsRegister()) { 2217 if (instr->value()->IsRegister()) {
2207 Register input = ToRegister(instr->value()); 2218 Register input = ToRegister(instr->value());
2208 is_smi = masm()->CheckSmi(input); 2219 is_smi = masm()->CheckSmi(input);
2209 } else { 2220 } else {
2210 Operand input = ToOperand(instr->value()); 2221 Operand input = ToOperand(instr->value());
2211 is_smi = masm()->CheckSmi(input); 2222 is_smi = masm()->CheckSmi(input);
2212 } 2223 }
2213 EmitBranch(true_block, false_block, is_smi); 2224 EmitBranch(true_block, false_block, is_smi);
2214 } 2225 }
2215 2226
2216 2227
2217 void LCodeGen::DoIsUndetectableAndBranch(LIsUndetectableAndBranch* instr) { 2228 void LCodeGen::DoIsUndetectableAndBranch(LIsUndetectableAndBranch* instr) {
2218 Register input = ToRegister(instr->value()); 2229 Register input = ToRegister(instr->value());
2219 Register temp = ToRegister(instr->temp()); 2230 Register temp = ToRegister(instr->temp());
2220 2231
2221 int true_block = chunk_->LookupDestination(instr->true_block_id()); 2232 int true_block = chunk_->LookupDestination(instr->true_block_id());
2222 int false_block = chunk_->LookupDestination(instr->false_block_id()); 2233 int false_block = chunk_->LookupDestination(instr->false_block_id());
2223 2234
2224 __ JumpIfSmi(input, chunk_->GetAssemblyLabel(false_block)); 2235 if (!instr->hydrogen()->value()->IsHeapObject()) {
2236 __ JumpIfSmi(input, chunk_->GetAssemblyLabel(false_block));
2237 }
2225 __ movq(temp, FieldOperand(input, HeapObject::kMapOffset)); 2238 __ movq(temp, FieldOperand(input, HeapObject::kMapOffset));
2226 __ testb(FieldOperand(temp, Map::kBitFieldOffset), 2239 __ testb(FieldOperand(temp, Map::kBitFieldOffset),
2227 Immediate(1 << Map::kIsUndetectable)); 2240 Immediate(1 << Map::kIsUndetectable));
2228 EmitBranch(true_block, false_block, not_zero); 2241 EmitBranch(true_block, false_block, not_zero);
2229 } 2242 }
2230 2243
2231 2244
2232 void LCodeGen::DoStringCompareAndBranch(LStringCompareAndBranch* instr) { 2245 void LCodeGen::DoStringCompareAndBranch(LStringCompareAndBranch* instr) {
2233 Token::Value op = instr->op(); 2246 Token::Value op = instr->op();
2234 int true_block = chunk_->LookupDestination(instr->true_block_id()); 2247 int true_block = chunk_->LookupDestination(instr->true_block_id());
(...skipping 30 matching lines...) Expand all
2265 2278
2266 2279
2267 void LCodeGen::DoHasInstanceTypeAndBranch(LHasInstanceTypeAndBranch* instr) { 2280 void LCodeGen::DoHasInstanceTypeAndBranch(LHasInstanceTypeAndBranch* instr) {
2268 Register input = ToRegister(instr->value()); 2281 Register input = ToRegister(instr->value());
2269 2282
2270 int true_block = chunk_->LookupDestination(instr->true_block_id()); 2283 int true_block = chunk_->LookupDestination(instr->true_block_id());
2271 int false_block = chunk_->LookupDestination(instr->false_block_id()); 2284 int false_block = chunk_->LookupDestination(instr->false_block_id());
2272 2285
2273 Label* false_label = chunk_->GetAssemblyLabel(false_block); 2286 Label* false_label = chunk_->GetAssemblyLabel(false_block);
2274 2287
2275 __ JumpIfSmi(input, false_label); 2288 if (!instr->hydrogen()->value()->IsHeapObject()) {
2289 __ JumpIfSmi(input, false_label);
2290 }
2276 2291
2277 __ CmpObjectType(input, TestType(instr->hydrogen()), kScratchRegister); 2292 __ CmpObjectType(input, TestType(instr->hydrogen()), kScratchRegister);
2278 EmitBranch(true_block, false_block, BranchCondition(instr->hydrogen())); 2293 EmitBranch(true_block, false_block, BranchCondition(instr->hydrogen()));
2279 } 2294 }
2280 2295
2281 2296
2282 void LCodeGen::DoGetCachedArrayIndex(LGetCachedArrayIndex* instr) { 2297 void LCodeGen::DoGetCachedArrayIndex(LGetCachedArrayIndex* instr) {
2283 Register input = ToRegister(instr->value()); 2298 Register input = ToRegister(instr->value());
2284 Register result = ToRegister(instr->result()); 2299 Register result = ToRegister(instr->result());
2285 2300
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
2685 __ CompareRoot(target, Heap::kTheHoleValueRootIndex); 2700 __ CompareRoot(target, Heap::kTheHoleValueRootIndex);
2686 if (instr->hydrogen()->DeoptimizesOnHole()) { 2701 if (instr->hydrogen()->DeoptimizesOnHole()) {
2687 DeoptimizeIf(equal, instr->environment()); 2702 DeoptimizeIf(equal, instr->environment());
2688 } else { 2703 } else {
2689 __ j(not_equal, &skip_assignment); 2704 __ j(not_equal, &skip_assignment);
2690 } 2705 }
2691 } 2706 }
2692 __ movq(target, value); 2707 __ movq(target, value);
2693 2708
2694 if (instr->hydrogen()->NeedsWriteBarrier()) { 2709 if (instr->hydrogen()->NeedsWriteBarrier()) {
2695 HType type = instr->hydrogen()->value()->type();
2696 SmiCheck check_needed = 2710 SmiCheck check_needed =
2697 type.IsHeapObject() ? OMIT_SMI_CHECK : INLINE_SMI_CHECK; 2711 instr->hydrogen()->value()->IsHeapObject()
2712 ? OMIT_SMI_CHECK : INLINE_SMI_CHECK;
2698 int offset = Context::SlotOffset(instr->slot_index()); 2713 int offset = Context::SlotOffset(instr->slot_index());
2699 Register scratch = ToRegister(instr->temp()); 2714 Register scratch = ToRegister(instr->temp());
2700 __ RecordWriteContextSlot(context, 2715 __ RecordWriteContextSlot(context,
2701 offset, 2716 offset,
2702 value, 2717 value,
2703 scratch, 2718 scratch,
2704 kSaveFPRegs, 2719 kSaveFPRegs,
2705 EMIT_REMEMBERED_SET, 2720 EMIT_REMEMBERED_SET,
2706 check_needed); 2721 check_needed);
2707 } 2722 }
(...skipping 1305 matching lines...) Expand 10 before | Expand all | Expand 10 after
4013 HeapObject::kMapOffset, 4028 HeapObject::kMapOffset,
4014 kScratchRegister, 4029 kScratchRegister,
4015 temp, 4030 temp,
4016 kSaveFPRegs, 4031 kSaveFPRegs,
4017 OMIT_REMEMBERED_SET, 4032 OMIT_REMEMBERED_SET,
4018 OMIT_SMI_CHECK); 4033 OMIT_SMI_CHECK);
4019 } 4034 }
4020 } 4035 }
4021 4036
4022 // Do the store. 4037 // Do the store.
4023 HType type = instr->hydrogen()->value()->type();
4024 SmiCheck check_needed = 4038 SmiCheck check_needed =
4025 type.IsHeapObject() ? OMIT_SMI_CHECK : INLINE_SMI_CHECK; 4039 instr->hydrogen()->value()->IsHeapObject()
4040 ? OMIT_SMI_CHECK : INLINE_SMI_CHECK;
4026 4041
4027 Register write_register = object; 4042 Register write_register = object;
4028 if (!access.IsInobject()) { 4043 if (!access.IsInobject()) {
4029 write_register = ToRegister(instr->temp()); 4044 write_register = ToRegister(instr->temp());
4030 __ movq(write_register, FieldOperand(object, JSObject::kPropertiesOffset)); 4045 __ movq(write_register, FieldOperand(object, JSObject::kPropertiesOffset));
4031 } 4046 }
4032 4047
4033 if (instr->value()->IsConstantOperand()) { 4048 if (instr->value()->IsConstantOperand()) {
4034 LConstantOperand* operand_value = LConstantOperand::cast(instr->value()); 4049 LConstantOperand* operand_value = LConstantOperand::cast(instr->value());
4035 if (operand_value->IsRegister()) { 4050 if (operand_value->IsRegister()) {
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
4254 } else { 4269 } else {
4255 Handle<Object> handle_value = ToHandle(operand_value); 4270 Handle<Object> handle_value = ToHandle(operand_value);
4256 __ Move(operand, handle_value); 4271 __ Move(operand, handle_value);
4257 } 4272 }
4258 } 4273 }
4259 4274
4260 if (instr->hydrogen()->NeedsWriteBarrier()) { 4275 if (instr->hydrogen()->NeedsWriteBarrier()) {
4261 ASSERT(instr->value()->IsRegister()); 4276 ASSERT(instr->value()->IsRegister());
4262 Register value = ToRegister(instr->value()); 4277 Register value = ToRegister(instr->value());
4263 ASSERT(!instr->key()->IsConstantOperand()); 4278 ASSERT(!instr->key()->IsConstantOperand());
4264 HType type = instr->hydrogen()->value()->type();
4265 SmiCheck check_needed = 4279 SmiCheck check_needed =
4266 type.IsHeapObject() ? OMIT_SMI_CHECK : INLINE_SMI_CHECK; 4280 instr->hydrogen()->value()->IsHeapObject()
4281 ? OMIT_SMI_CHECK : INLINE_SMI_CHECK;
4267 // Compute address of modified element and store it into key register. 4282 // Compute address of modified element and store it into key register.
4268 Register key_reg(ToRegister(key)); 4283 Register key_reg(ToRegister(key));
4269 __ lea(key_reg, operand); 4284 __ lea(key_reg, operand);
4270 __ RecordWrite(elements, 4285 __ RecordWrite(elements,
4271 key_reg, 4286 key_reg,
4272 value, 4287 value,
4273 kSaveFPRegs, 4288 kSaveFPRegs,
4274 EMIT_REMEMBERED_SET, 4289 EMIT_REMEMBERED_SET,
4275 check_needed); 4290 check_needed);
4276 } 4291 }
(...skipping 1327 matching lines...) Expand 10 before | Expand all | Expand 10 after
5604 FixedArray::kHeaderSize - kPointerSize)); 5619 FixedArray::kHeaderSize - kPointerSize));
5605 __ bind(&done); 5620 __ bind(&done);
5606 } 5621 }
5607 5622
5608 5623
5609 #undef __ 5624 #undef __
5610 5625
5611 } } // namespace v8::internal 5626 } } // namespace v8::internal
5612 5627
5613 #endif // V8_TARGET_ARCH_X64 5628 #endif // V8_TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698