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

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

Issue 246423005: Improve code generation for bounds checks. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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.h ('k') | src/ia32/lithium-ia32.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 4479 matching lines...) Expand 10 before | Expand all | Expand 10 after
4490 ASSERT(ToRegister(instr->context()).is(esi)); 4490 ASSERT(ToRegister(instr->context()).is(esi));
4491 ASSERT(ToRegister(instr->object()).is(edx)); 4491 ASSERT(ToRegister(instr->object()).is(edx));
4492 ASSERT(ToRegister(instr->value()).is(eax)); 4492 ASSERT(ToRegister(instr->value()).is(eax));
4493 4493
4494 __ mov(ecx, instr->name()); 4494 __ mov(ecx, instr->name());
4495 Handle<Code> ic = StoreIC::initialize_stub(isolate(), instr->strict_mode()); 4495 Handle<Code> ic = StoreIC::initialize_stub(isolate(), instr->strict_mode());
4496 CallCode(ic, RelocInfo::CODE_TARGET, instr); 4496 CallCode(ic, RelocInfo::CODE_TARGET, instr);
4497 } 4497 }
4498 4498
4499 4499
4500 void LCodeGen::ApplyCheckIf(Condition cc, LBoundsCheck* check) { 4500 void LCodeGen::DoBoundsCheck(LBoundsCheck* instr) {
4501 if (FLAG_debug_code && check->hydrogen()->skip_check()) { 4501 Condition cc = instr->hydrogen()->allow_equality() ? above : above_equal;
4502 if (instr->index()->IsConstantOperand()) {
4503 __ cmp(ToOperand(instr->length()),
4504 ToImmediate(LConstantOperand::cast(instr->index()),
4505 instr->hydrogen()->length()->representation()));
4506 cc = ReverseCondition(cc);
4507 } else if (instr->length()->IsConstantOperand()) {
4508 __ cmp(ToOperand(instr->index()),
4509 ToImmediate(LConstantOperand::cast(instr->length()),
4510 instr->hydrogen()->index()->representation()));
4511 } else {
4512 __ cmp(ToRegister(instr->index()), ToOperand(instr->length()));
4513 }
4514 if (FLAG_debug_code && instr->hydrogen()->skip_check()) {
4502 Label done; 4515 Label done;
4503 __ j(NegateCondition(cc), &done, Label::kNear); 4516 __ j(NegateCondition(cc), &done, Label::kNear);
4504 __ int3(); 4517 __ int3();
4505 __ bind(&done); 4518 __ bind(&done);
4506 } else { 4519 } else {
4507 DeoptimizeIf(cc, check->environment()); 4520 DeoptimizeIf(cc, instr->environment());
4508 } 4521 }
4509 } 4522 }
4510 4523
4511
4512 void LCodeGen::DoBoundsCheck(LBoundsCheck* instr) {
4513 if (instr->hydrogen()->skip_check() && !FLAG_debug_code) return;
4514
4515 if (instr->index()->IsConstantOperand()) {
4516 Immediate immediate =
4517 ToImmediate(LConstantOperand::cast(instr->index()),
4518 instr->hydrogen()->length()->representation());
4519 __ cmp(ToOperand(instr->length()), immediate);
4520 Condition condition =
4521 instr->hydrogen()->allow_equality() ? below : below_equal;
4522 ApplyCheckIf(condition, instr);
4523 } else {
4524 __ cmp(ToRegister(instr->index()), ToOperand(instr->length()));
4525 Condition condition =
4526 instr->hydrogen()->allow_equality() ? above : above_equal;
4527 ApplyCheckIf(condition, instr);
4528 }
4529 }
4530
4531 4524
4532 void LCodeGen::DoStoreKeyedExternalArray(LStoreKeyed* instr) { 4525 void LCodeGen::DoStoreKeyedExternalArray(LStoreKeyed* instr) {
4533 ElementsKind elements_kind = instr->elements_kind(); 4526 ElementsKind elements_kind = instr->elements_kind();
4534 LOperand* key = instr->key(); 4527 LOperand* key = instr->key();
4535 if (!key->IsConstantOperand() && 4528 if (!key->IsConstantOperand() &&
4536 ExternalArrayOpRequiresTemp(instr->hydrogen()->key()->representation(), 4529 ExternalArrayOpRequiresTemp(instr->hydrogen()->key()->representation(),
4537 elements_kind)) { 4530 elements_kind)) {
4538 __ SmiUntag(ToRegister(key)); 4531 __ SmiUntag(ToRegister(key));
4539 } 4532 }
4540 Operand operand(BuildFastArrayOperand( 4533 Operand operand(BuildFastArrayOperand(
(...skipping 1908 matching lines...) Expand 10 before | Expand all | Expand 10 after
6449 __ bind(deferred->exit()); 6442 __ bind(deferred->exit());
6450 __ bind(&done); 6443 __ bind(&done);
6451 } 6444 }
6452 6445
6453 6446
6454 #undef __ 6447 #undef __
6455 6448
6456 } } // namespace v8::internal 6449 } } // namespace v8::internal
6457 6450
6458 #endif // V8_TARGET_ARCH_IA32 6451 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/lithium-codegen-ia32.h ('k') | src/ia32/lithium-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698