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

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

Issue 21392: Change compiler to safely write unsafe smis when they are spilled from... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/toiger/
Patch Set: '' Created 11 years, 10 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/codegen-ia32.h ('k') | src/register-allocator-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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 1299 matching lines...) Expand 10 before | Expand all | Expand 10 after
1310 Result result = frame_->CallStub(&stub, &left_side, &right_side, 0); 1310 Result result = frame_->CallStub(&stub, &left_side, &right_side, 0);
1311 result.ToRegister(); 1311 result.ToRegister();
1312 __ cmp(result.reg(), 0); 1312 __ cmp(result.reg(), 0);
1313 result.Unuse(); 1313 result.Unuse();
1314 dest->true_target()->Branch(cc); 1314 dest->true_target()->Branch(cc);
1315 dest->false_target()->Jump(); 1315 dest->false_target()->Jump();
1316 1316
1317 is_smi.Bind(&left_side, &right_side); 1317 is_smi.Bind(&left_side, &right_side);
1318 left_side.ToRegister(); 1318 left_side.ToRegister();
1319 // Test smi equality and comparison by signed int comparison. 1319 // Test smi equality and comparison by signed int comparison.
1320 if (IsUnsafeSmi(right_side.handle())) {
1321 right_side.ToRegister();
1322 ASSERT(right_side.is_valid());
1323 __ cmp(left_side.reg(), Operand(right_side.reg()));
1324 } else {
1320 __ cmp(Operand(left_side.reg()), Immediate(right_side.handle())); 1325 __ cmp(Operand(left_side.reg()), Immediate(right_side.handle()));
1326 }
iposva 2009/02/17 17:27:06 This apparently survived your purge of unrelated s
William Hesse 2009/02/18 09:04:56 This is not an unrelated change. It is one of the
1321 left_side.Unuse(); 1327 left_side.Unuse();
1322 right_side.Unuse(); 1328 right_side.Unuse();
1323 dest->Split(cc); 1329 dest->Split(cc);
1324 } 1330 }
1325 } else { // Neither side is a constant Smi, normal comparison operation. 1331 } else { // Neither side is a constant Smi, normal comparison operation.
1326 left_side.ToRegister(); 1332 left_side.ToRegister();
1327 right_side.ToRegister(); 1333 right_side.ToRegister();
1328 ASSERT(left_side.is_valid()); 1334 ASSERT(left_side.is_valid());
1329 ASSERT(right_side.is_valid()); 1335 ASSERT(right_side.is_valid());
1330 // Check for the smi case. 1336 // Check for the smi case.
(...skipping 1707 matching lines...) Expand 10 before | Expand all | Expand 10 after
3038 } else { 3044 } else {
3039 ASSERT(var->is_global()); 3045 ASSERT(var->is_global());
3040 Reference ref(this, node); 3046 Reference ref(this, node);
3041 ref.GetValue(typeof_state()); 3047 ref.GetValue(typeof_state());
3042 } 3048 }
3043 } 3049 }
3044 3050
3045 3051
3046 void CodeGenerator::VisitLiteral(Literal* node) { 3052 void CodeGenerator::VisitLiteral(Literal* node) {
3047 Comment cmnt(masm_, "[ Literal"); 3053 Comment cmnt(masm_, "[ Literal");
3048 if (node->handle()->IsSmi() && !IsInlineSmi(node)) {
3049 // To prevent long attacker-controlled byte sequences in code, larger
3050 // Smis are loaded in two steps via a temporary register.
3051 Result temp = allocator_->Allocate();
3052 ASSERT(temp.is_valid());
3053 int bits = reinterpret_cast<int>(*node->handle());
3054 __ Set(temp.reg(), Immediate(bits & 0x0000FFFF));
3055 __ xor_(temp.reg(), bits & 0xFFFF0000);
3056 frame_->Push(&temp);
3057 } else {
3058 frame_->Push(node->handle()); 3054 frame_->Push(node->handle());
3059 } 3055 }
3056
3057
3058 void CodeGenerator::LoadUnsafeSmi(Register target, Handle<Object> value) {
3059 ASSERT(target.is_valid());
3060 ASSERT(value->IsSmi());
3061 int bits = reinterpret_cast<int>(*value);
3062 __ Set(target, Immediate(bits & 0x0000FFFF));
3063 __ xor_(target, bits & 0xFFFF0000);
3064 }
3065
3066
3067 bool CodeGenerator::IsUnsafeSmi(Handle<Object> value) {
3068 if (!value->IsSmi()) return false;
3069 int int_value = Smi::cast(*value)->value();
3070 return !is_intn(int_value, kMaxSmiInlinedBits);
3060 } 3071 }
3061 3072
3062 3073
3063 class DeferredRegExpLiteral: public DeferredCode { 3074 class DeferredRegExpLiteral: public DeferredCode {
3064 public: 3075 public:
3065 DeferredRegExpLiteral(CodeGenerator* generator, RegExpLiteral* node) 3076 DeferredRegExpLiteral(CodeGenerator* generator, RegExpLiteral* node)
3066 : DeferredCode(generator), node_(node) { 3077 : DeferredCode(generator), node_(node) {
3067 set_comment("[ DeferredRegExpLiteral"); 3078 set_comment("[ DeferredRegExpLiteral");
3068 } 3079 }
3069 3080
(...skipping 3485 matching lines...) Expand 10 before | Expand all | Expand 10 after
6555 6566
6556 // Slow-case: Go through the JavaScript implementation. 6567 // Slow-case: Go through the JavaScript implementation.
6557 __ bind(&slow); 6568 __ bind(&slow);
6558 __ InvokeBuiltin(Builtins::INSTANCE_OF, JUMP_FUNCTION); 6569 __ InvokeBuiltin(Builtins::INSTANCE_OF, JUMP_FUNCTION);
6559 } 6570 }
6560 6571
6561 6572
6562 #undef __ 6573 #undef __
6563 6574
6564 } } // namespace v8::internal 6575 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/codegen-ia32.h ('k') | src/register-allocator-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698