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

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

Issue 10829456: Check that index and length are Smi in bounds check. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Porting changes to ARM and ia32 Created 8 years, 4 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/arm/lithium-codegen-arm.h ('k') | src/ia32/lithium-codegen-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 3874 matching lines...) Expand 10 before | Expand all | Expand 10 after
3885 3885
3886 // Name is always in r2. 3886 // Name is always in r2.
3887 __ mov(r2, Operand(instr->name())); 3887 __ mov(r2, Operand(instr->name()));
3888 Handle<Code> ic = (instr->strict_mode_flag() == kStrictMode) 3888 Handle<Code> ic = (instr->strict_mode_flag() == kStrictMode)
3889 ? isolate()->builtins()->StoreIC_Initialize_Strict() 3889 ? isolate()->builtins()->StoreIC_Initialize_Strict()
3890 : isolate()->builtins()->StoreIC_Initialize(); 3890 : isolate()->builtins()->StoreIC_Initialize();
3891 CallCode(ic, RelocInfo::CODE_TARGET, instr); 3891 CallCode(ic, RelocInfo::CODE_TARGET, instr);
3892 } 3892 }
3893 3893
3894 3894
3895 void LCodeGen::DeoptIfTaggedButNotSmi(LEnvironment* environment,
3896 HValue* value,
3897 LOperand* operand) {
3898 if (value->representation().IsTagged() && !value->type().IsSmi()) {
3899 if (operand->IsRegister()) {
3900 __ tst(ToRegister(operand), Operand(kSmiTagMask));
3901 } else {
3902 __ mov(ip, ToOperand(operand));
3903 __ tst(ip, Operand(kSmiTagMask));
3904 }
3905 DeoptimizeIf(ne, environment);
3906 }
3907 }
3908
3909
3895 void LCodeGen::DoBoundsCheck(LBoundsCheck* instr) { 3910 void LCodeGen::DoBoundsCheck(LBoundsCheck* instr) {
3911 DeoptIfTaggedButNotSmi(instr->environment(),
3912 instr->hydrogen()->length(),
3913 instr->length());
3914 DeoptIfTaggedButNotSmi(instr->environment(),
3915 instr->hydrogen()->index(),
3916 instr->index());
3896 if (instr->index()->IsConstantOperand()) { 3917 if (instr->index()->IsConstantOperand()) {
3897 int constant_index = 3918 int constant_index =
3898 ToInteger32(LConstantOperand::cast(instr->index())); 3919 ToInteger32(LConstantOperand::cast(instr->index()));
3899 if (instr->hydrogen()->length()->representation().IsTagged()) { 3920 if (instr->hydrogen()->length()->representation().IsTagged()) {
3900 __ mov(ip, Operand(Smi::FromInt(constant_index))); 3921 __ mov(ip, Operand(Smi::FromInt(constant_index)));
3901 } else { 3922 } else {
3902 __ mov(ip, Operand(constant_index)); 3923 __ mov(ip, Operand(constant_index));
3903 } 3924 }
3904 __ cmp(ip, ToRegister(instr->length())); 3925 __ cmp(ip, ToRegister(instr->length()));
3905 } else { 3926 } else {
(...skipping 1623 matching lines...) Expand 10 before | Expand all | Expand 10 after
5529 __ sub(scratch, result, Operand(index, LSL, kPointerSizeLog2 - kSmiTagSize)); 5550 __ sub(scratch, result, Operand(index, LSL, kPointerSizeLog2 - kSmiTagSize));
5530 __ ldr(result, FieldMemOperand(scratch, 5551 __ ldr(result, FieldMemOperand(scratch,
5531 FixedArray::kHeaderSize - kPointerSize)); 5552 FixedArray::kHeaderSize - kPointerSize));
5532 __ bind(&done); 5553 __ bind(&done);
5533 } 5554 }
5534 5555
5535 5556
5536 #undef __ 5557 #undef __
5537 5558
5538 } } // namespace v8::internal 5559 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arm/lithium-codegen-arm.h ('k') | src/ia32/lithium-codegen-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698