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

Side by Side Diff: runtime/vm/intermediate_language_ia32.cc

Issue 10883063: Add explicit smi checks for unary smi operations. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 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 | « runtime/vm/intermediate_language.h ('k') | runtime/vm/intermediate_language_x64.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 (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32.
6 #if defined(TARGET_ARCH_IA32) 6 #if defined(TARGET_ARCH_IA32)
7 7
8 #include "vm/intermediate_language.h" 8 #include "vm/intermediate_language.h"
9 9
10 #include "lib/error.h" 10 #include "lib/error.h"
(...skipping 1944 matching lines...) Expand 10 before | Expand all | Expand 10 after
1955 const intptr_t kNumTemps = 0; 1955 const intptr_t kNumTemps = 0;
1956 LocationSummary* summary = 1956 LocationSummary* summary =
1957 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); 1957 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
1958 summary->set_in(0, Location::RequiresRegister()); 1958 summary->set_in(0, Location::RequiresRegister());
1959 summary->set_out(Location::SameAsFirstInput()); 1959 summary->set_out(Location::SameAsFirstInput());
1960 return summary; 1960 return summary;
1961 } 1961 }
1962 1962
1963 1963
1964 void UnarySmiOpComp::EmitNativeCode(FlowGraphCompiler* compiler) { 1964 void UnarySmiOpComp::EmitNativeCode(FlowGraphCompiler* compiler) {
1965 const ICData& ic_data = *instance_call()->ic_data();
1966 ASSERT(!ic_data.IsNull());
1967 ASSERT(ic_data.num_args_tested() == 1);
1968 // TODO(srdjan): Implement for more checks.
1969 ASSERT(ic_data.NumberOfChecks() == 1);
1970 intptr_t test_class_id;
1971 Function& target = Function::Handle();
1972 ic_data.GetOneClassCheckAt(0, &test_class_id, &target);
1973
1974 Register value = locs()->in(0).reg(); 1965 Register value = locs()->in(0).reg();
1975 Register result = locs()->out().reg(); 1966 ASSERT(value == locs()->out().reg());
1976 ASSERT(value == result); 1967 switch (op_kind()) {
1977 Label* deopt = compiler->AddDeoptStub(instance_call()->deopt_id(), 1968 case Token::kNEGATE: {
1978 instance_call()->try_index(), 1969 Label* deopt = compiler->AddDeoptStub(instance_call()->deopt_id(),
1979 kDeoptUnaryOp); 1970 instance_call()->try_index(),
1980 if (test_class_id == kSmiCid) { 1971 kDeoptUnaryOp);
1981 __ testl(value, Immediate(kSmiTagMask)); 1972 __ negl(value);
1982 __ j(NOT_ZERO, deopt); 1973 __ j(OVERFLOW, deopt);
1983 switch (op_kind()) { 1974 break;
1984 case Token::kNEGATE:
1985 __ negl(value);
1986 __ j(OVERFLOW, deopt);
1987 break;
1988 case Token::kBIT_NOT:
1989 __ notl(value);
1990 __ andl(value, Immediate(~kSmiTagMask)); // Remove inverted smi-tag.
1991 break;
1992 default:
1993 UNREACHABLE();
1994 } 1975 }
1995 } else { 1976 case Token::kBIT_NOT:
1996 UNREACHABLE(); 1977 __ notl(value);
1978 __ andl(value, Immediate(~kSmiTagMask)); // Remove inverted smi-tag.
1979 break;
1980 default:
1981 UNREACHABLE();
1997 } 1982 }
1998 } 1983 }
1999 1984
2000 1985
2001 LocationSummary* NumberNegateComp::MakeLocationSummary() const { 1986 LocationSummary* NumberNegateComp::MakeLocationSummary() const {
2002 const intptr_t kNumInputs = 1; 1987 const intptr_t kNumInputs = 1;
2003 const intptr_t kNumTemps = 1; // Needed for doubles. 1988 const intptr_t kNumTemps = 1; // Needed for doubles.
2004 LocationSummary* summary = 1989 LocationSummary* summary =
2005 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall); 1990 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall);
2006 summary->set_in(0, Location::RegisterLocation(EAX)); 1991 summary->set_in(0, Location::RegisterLocation(EAX));
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
2382 __ testl(value, Immediate(kSmiTagMask)); 2367 __ testl(value, Immediate(kSmiTagMask));
2383 __ j(NOT_ZERO, deopt); 2368 __ j(NOT_ZERO, deopt);
2384 } 2369 }
2385 2370
2386 2371
2387 } // namespace dart 2372 } // namespace dart
2388 2373
2389 #undef __ 2374 #undef __
2390 2375
2391 #endif // defined TARGET_ARCH_X64 2376 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language.h ('k') | runtime/vm/intermediate_language_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698