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

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

Issue 16026023: Avoid Unnecessary Smi Checks (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: address review Created 7 years, 5 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.h ('k') | src/ia32/lithium-ia32.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 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 1792 matching lines...) Expand 10 before | Expand all | Expand 10 after
1803 } 1803 }
1804 1804
1805 1805
1806 void LCodeGen::DoValueOf(LValueOf* instr) { 1806 void LCodeGen::DoValueOf(LValueOf* instr) {
1807 Register input = ToRegister(instr->value()); 1807 Register input = ToRegister(instr->value());
1808 Register result = ToRegister(instr->result()); 1808 Register result = ToRegister(instr->result());
1809 Register map = ToRegister(instr->temp()); 1809 Register map = ToRegister(instr->temp());
1810 ASSERT(input.is(result)); 1810 ASSERT(input.is(result));
1811 1811
1812 Label done; 1812 Label done;
1813 // If the object is a smi return the object. 1813
1814 __ JumpIfSmi(input, &done, Label::kNear); 1814 if (!instr->hydrogen()->value()->IsHeapObject()) {
1815 // If the object is a smi return the object.
1816 __ JumpIfSmi(input, &done, Label::kNear);
1817 }
1815 1818
1816 // If the object is not a value type, return the object. 1819 // If the object is not a value type, return the object.
1817 __ CmpObjectType(input, JS_VALUE_TYPE, map); 1820 __ CmpObjectType(input, JS_VALUE_TYPE, map);
1818 __ j(not_equal, &done, Label::kNear); 1821 __ j(not_equal, &done, Label::kNear);
1819 __ mov(result, FieldOperand(input, JSValue::kValueOffset)); 1822 __ mov(result, FieldOperand(input, JSValue::kValueOffset));
1820 1823
1821 __ bind(&done); 1824 __ bind(&done);
1822 } 1825 }
1823 1826
1824 1827
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after
2357 2360
2358 Condition true_cond = EmitIsObject( 2361 Condition true_cond = EmitIsObject(
2359 reg, temp, instr->FalseLabel(chunk_), instr->TrueLabel(chunk_)); 2362 reg, temp, instr->FalseLabel(chunk_), instr->TrueLabel(chunk_));
2360 2363
2361 EmitBranch(instr, true_cond); 2364 EmitBranch(instr, true_cond);
2362 } 2365 }
2363 2366
2364 2367
2365 Condition LCodeGen::EmitIsString(Register input, 2368 Condition LCodeGen::EmitIsString(Register input,
2366 Register temp1, 2369 Register temp1,
2367 Label* is_not_string) { 2370 Label* is_not_string,
2368 __ JumpIfSmi(input, is_not_string); 2371 SmiCheck check_needed = INLINE_SMI_CHECK) {
2372 if (check_needed == INLINE_SMI_CHECK) {
2373 __ JumpIfSmi(input, is_not_string);
2374 }
2369 2375
2370 Condition cond = masm_->IsObjectStringType(input, temp1, temp1); 2376 Condition cond = masm_->IsObjectStringType(input, temp1, temp1);
2371 2377
2372 return cond; 2378 return cond;
2373 } 2379 }
2374 2380
2375 2381
2376 void LCodeGen::DoIsStringAndBranch(LIsStringAndBranch* instr) { 2382 void LCodeGen::DoIsStringAndBranch(LIsStringAndBranch* instr) {
2377 Register reg = ToRegister(instr->value()); 2383 Register reg = ToRegister(instr->value());
2378 Register temp = ToRegister(instr->temp()); 2384 Register temp = ToRegister(instr->temp());
2379 2385
2380 Condition true_cond = EmitIsString(reg, temp, instr->FalseLabel(chunk_)); 2386 SmiCheck check_needed =
2387 instr->hydrogen()->value()->IsHeapObject()
2388 ? OMIT_SMI_CHECK : INLINE_SMI_CHECK;
2389
2390 Condition true_cond = EmitIsString(
2391 reg, temp, instr->FalseLabel(chunk_), check_needed);
2381 2392
2382 EmitBranch(instr, true_cond); 2393 EmitBranch(instr, true_cond);
2383 } 2394 }
2384 2395
2385 2396
2386 void LCodeGen::DoIsSmiAndBranch(LIsSmiAndBranch* instr) { 2397 void LCodeGen::DoIsSmiAndBranch(LIsSmiAndBranch* instr) {
2387 Operand input = ToOperand(instr->value()); 2398 Operand input = ToOperand(instr->value());
2388 2399
2389 __ test(input, Immediate(kSmiTagMask)); 2400 __ test(input, Immediate(kSmiTagMask));
2390 EmitBranch(instr, zero); 2401 EmitBranch(instr, zero);
2391 } 2402 }
2392 2403
2393 2404
2394 void LCodeGen::DoIsUndetectableAndBranch(LIsUndetectableAndBranch* instr) { 2405 void LCodeGen::DoIsUndetectableAndBranch(LIsUndetectableAndBranch* instr) {
2395 Register input = ToRegister(instr->value()); 2406 Register input = ToRegister(instr->value());
2396 Register temp = ToRegister(instr->temp()); 2407 Register temp = ToRegister(instr->temp());
2397 2408
2398 STATIC_ASSERT(kSmiTag == 0); 2409 if (!instr->hydrogen()->value()->IsHeapObject()) {
2399 __ JumpIfSmi(input, instr->FalseLabel(chunk_)); 2410 STATIC_ASSERT(kSmiTag == 0);
2411 __ JumpIfSmi(input, instr->FalseLabel(chunk_));
2412 }
2400 __ mov(temp, FieldOperand(input, HeapObject::kMapOffset)); 2413 __ mov(temp, FieldOperand(input, HeapObject::kMapOffset));
2401 __ test_b(FieldOperand(temp, Map::kBitFieldOffset), 2414 __ test_b(FieldOperand(temp, Map::kBitFieldOffset),
2402 1 << Map::kIsUndetectable); 2415 1 << Map::kIsUndetectable);
2403 EmitBranch(instr, not_zero); 2416 EmitBranch(instr, not_zero);
2404 } 2417 }
2405 2418
2406 2419
2407 static Condition ComputeCompareCondition(Token::Value op) { 2420 static Condition ComputeCompareCondition(Token::Value op) {
2408 switch (op) { 2421 switch (op) {
2409 case Token::EQ_STRICT: 2422 case Token::EQ_STRICT:
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
2454 if (from == FIRST_TYPE) return below_equal; 2467 if (from == FIRST_TYPE) return below_equal;
2455 UNREACHABLE(); 2468 UNREACHABLE();
2456 return equal; 2469 return equal;
2457 } 2470 }
2458 2471
2459 2472
2460 void LCodeGen::DoHasInstanceTypeAndBranch(LHasInstanceTypeAndBranch* instr) { 2473 void LCodeGen::DoHasInstanceTypeAndBranch(LHasInstanceTypeAndBranch* instr) {
2461 Register input = ToRegister(instr->value()); 2474 Register input = ToRegister(instr->value());
2462 Register temp = ToRegister(instr->temp()); 2475 Register temp = ToRegister(instr->temp());
2463 2476
2464 __ JumpIfSmi(input, instr->FalseLabel(chunk_)); 2477 if (!instr->hydrogen()->value()->IsHeapObject()) {
2478 __ JumpIfSmi(input, instr->FalseLabel(chunk_));
2479 }
2465 2480
2466 __ CmpObjectType(input, TestType(instr->hydrogen()), temp); 2481 __ CmpObjectType(input, TestType(instr->hydrogen()), temp);
2467 EmitBranch(instr, BranchCondition(instr->hydrogen())); 2482 EmitBranch(instr, BranchCondition(instr->hydrogen()));
2468 } 2483 }
2469 2484
2470 2485
2471 void LCodeGen::DoGetCachedArrayIndex(LGetCachedArrayIndex* instr) { 2486 void LCodeGen::DoGetCachedArrayIndex(LGetCachedArrayIndex* instr) {
2472 Register input = ToRegister(instr->value()); 2487 Register input = ToRegister(instr->value());
2473 Register result = ToRegister(instr->result()); 2488 Register result = ToRegister(instr->result());
2474 2489
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
2891 __ cmp(target, factory()->the_hole_value()); 2906 __ cmp(target, factory()->the_hole_value());
2892 if (instr->hydrogen()->DeoptimizesOnHole()) { 2907 if (instr->hydrogen()->DeoptimizesOnHole()) {
2893 DeoptimizeIf(equal, instr->environment()); 2908 DeoptimizeIf(equal, instr->environment());
2894 } else { 2909 } else {
2895 __ j(not_equal, &skip_assignment, Label::kNear); 2910 __ j(not_equal, &skip_assignment, Label::kNear);
2896 } 2911 }
2897 } 2912 }
2898 2913
2899 __ mov(target, value); 2914 __ mov(target, value);
2900 if (instr->hydrogen()->NeedsWriteBarrier()) { 2915 if (instr->hydrogen()->NeedsWriteBarrier()) {
2901 HType type = instr->hydrogen()->value()->type();
2902 SmiCheck check_needed = 2916 SmiCheck check_needed =
2903 type.IsHeapObject() ? OMIT_SMI_CHECK : INLINE_SMI_CHECK; 2917 instr->hydrogen()->value()->IsHeapObject()
2918 ? OMIT_SMI_CHECK : INLINE_SMI_CHECK;
2904 Register temp = ToRegister(instr->temp()); 2919 Register temp = ToRegister(instr->temp());
2905 int offset = Context::SlotOffset(instr->slot_index()); 2920 int offset = Context::SlotOffset(instr->slot_index());
2906 __ RecordWriteContextSlot(context, 2921 __ RecordWriteContextSlot(context,
2907 offset, 2922 offset,
2908 value, 2923 value,
2909 temp, 2924 temp,
2910 GetSaveFPRegsMode(), 2925 GetSaveFPRegsMode(),
2911 EMIT_REMEMBERED_SET, 2926 EMIT_REMEMBERED_SET,
2912 check_needed); 2927 check_needed);
2913 } 2928 }
(...skipping 1348 matching lines...) Expand 10 before | Expand all | Expand 10 after
4262 HeapObject::kMapOffset, 4277 HeapObject::kMapOffset,
4263 temp_map, 4278 temp_map,
4264 temp, 4279 temp,
4265 GetSaveFPRegsMode(), 4280 GetSaveFPRegsMode(),
4266 OMIT_REMEMBERED_SET, 4281 OMIT_REMEMBERED_SET,
4267 OMIT_SMI_CHECK); 4282 OMIT_SMI_CHECK);
4268 } 4283 }
4269 } 4284 }
4270 4285
4271 // Do the store. 4286 // Do the store.
4272 HType type = instr->hydrogen()->value()->type();
4273 SmiCheck check_needed = 4287 SmiCheck check_needed =
4274 type.IsHeapObject() ? OMIT_SMI_CHECK : INLINE_SMI_CHECK; 4288 instr->hydrogen()->value()->IsHeapObject()
4289 ? OMIT_SMI_CHECK : INLINE_SMI_CHECK;
4275 4290
4276 Register write_register = object; 4291 Register write_register = object;
4277 if (!access.IsInobject()) { 4292 if (!access.IsInobject()) {
4278 write_register = ToRegister(instr->temp()); 4293 write_register = ToRegister(instr->temp());
4279 __ mov(write_register, 4294 __ mov(write_register,
4280 FieldOperand(object, JSObject::kPropertiesOffset)); 4295 FieldOperand(object, JSObject::kPropertiesOffset));
4281 } 4296 }
4282 4297
4283 if (instr->value()->IsConstantOperand()) { 4298 if (instr->value()->IsConstantOperand()) {
4284 LConstantOperand* operand_value = LConstantOperand::cast(instr->value()); 4299 LConstantOperand* operand_value = LConstantOperand::cast(instr->value());
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
4501 } else { 4516 } else {
4502 Handle<Object> handle_value = ToHandle(operand_value); 4517 Handle<Object> handle_value = ToHandle(operand_value);
4503 __ mov(operand, handle_value); 4518 __ mov(operand, handle_value);
4504 } 4519 }
4505 } 4520 }
4506 4521
4507 if (instr->hydrogen()->NeedsWriteBarrier()) { 4522 if (instr->hydrogen()->NeedsWriteBarrier()) {
4508 ASSERT(instr->value()->IsRegister()); 4523 ASSERT(instr->value()->IsRegister());
4509 Register value = ToRegister(instr->value()); 4524 Register value = ToRegister(instr->value());
4510 ASSERT(!instr->key()->IsConstantOperand()); 4525 ASSERT(!instr->key()->IsConstantOperand());
4511 HType type = instr->hydrogen()->value()->type();
4512 SmiCheck check_needed = 4526 SmiCheck check_needed =
4513 type.IsHeapObject() ? OMIT_SMI_CHECK : INLINE_SMI_CHECK; 4527 instr->hydrogen()->value()->IsHeapObject()
4528 ? OMIT_SMI_CHECK : INLINE_SMI_CHECK;
4514 // Compute address of modified element and store it into key register. 4529 // Compute address of modified element and store it into key register.
4515 __ lea(key, operand); 4530 __ lea(key, operand);
4516 __ RecordWrite(elements, 4531 __ RecordWrite(elements,
4517 key, 4532 key,
4518 value, 4533 value,
4519 GetSaveFPRegsMode(), 4534 GetSaveFPRegsMode(),
4520 EMIT_REMEMBERED_SET, 4535 EMIT_REMEMBERED_SET,
4521 check_needed); 4536 check_needed);
4522 } 4537 }
4523 } 4538 }
(...skipping 1121 matching lines...) Expand 10 before | Expand all | Expand 10 after
5645 5660
5646 5661
5647 void LCodeGen::DoCheckSmi(LCheckSmi* instr) { 5662 void LCodeGen::DoCheckSmi(LCheckSmi* instr) {
5648 LOperand* input = instr->value(); 5663 LOperand* input = instr->value();
5649 __ test(ToOperand(input), Immediate(kSmiTagMask)); 5664 __ test(ToOperand(input), Immediate(kSmiTagMask));
5650 DeoptimizeIf(not_zero, instr->environment()); 5665 DeoptimizeIf(not_zero, instr->environment());
5651 } 5666 }
5652 5667
5653 5668
5654 void LCodeGen::DoCheckNonSmi(LCheckNonSmi* instr) { 5669 void LCodeGen::DoCheckNonSmi(LCheckNonSmi* instr) {
5655 LOperand* input = instr->value(); 5670 if (!instr->hydrogen()->value()->IsHeapObject()) {
5656 __ test(ToOperand(input), Immediate(kSmiTagMask)); 5671 LOperand* input = instr->value();
5657 DeoptimizeIf(zero, instr->environment()); 5672 __ test(ToOperand(input), Immediate(kSmiTagMask));
5673 DeoptimizeIf(zero, instr->environment());
5674 }
5658 } 5675 }
5659 5676
5660 5677
5661 void LCodeGen::DoCheckInstanceType(LCheckInstanceType* instr) { 5678 void LCodeGen::DoCheckInstanceType(LCheckInstanceType* instr) {
5662 Register input = ToRegister(instr->value()); 5679 Register input = ToRegister(instr->value());
5663 Register temp = ToRegister(instr->temp()); 5680 Register temp = ToRegister(instr->temp());
5664 5681
5665 __ mov(temp, FieldOperand(input, HeapObject::kMapOffset)); 5682 __ mov(temp, FieldOperand(input, HeapObject::kMapOffset));
5666 5683
5667 if (instr->hydrogen()->is_interval_check()) { 5684 if (instr->hydrogen()->is_interval_check()) {
(...skipping 863 matching lines...) Expand 10 before | Expand all | Expand 10 after
6531 FixedArray::kHeaderSize - kPointerSize)); 6548 FixedArray::kHeaderSize - kPointerSize));
6532 __ bind(&done); 6549 __ bind(&done);
6533 } 6550 }
6534 6551
6535 6552
6536 #undef __ 6553 #undef __
6537 6554
6538 } } // namespace v8::internal 6555 } } // namespace v8::internal
6539 6556
6540 #endif // V8_TARGET_ARCH_IA32 6557 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/lithium-codegen-ia32.h ('k') | src/ia32/lithium-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698