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

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

Issue 11048032: Support for mixed null/smi equality: do not deoptimize, emit same optimized code as if that was smi… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 2 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
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" 5 #include "vm/globals.h"
6 #if defined(TARGET_ARCH_IA32) 6 #if defined(TARGET_ARCH_IA32)
7 7
8 #include "vm/assembler.h" 8 #include "vm/assembler.h"
9 #include "vm/assembler_macros.h" 9 #include "vm/assembler_macros.h"
10 #include "vm/compiler.h" 10 #include "vm/compiler.h"
(...skipping 1947 matching lines...) Expand 10 before | Expand all | Expand 10 after
1958 // TOS + 4: error object 1958 // TOS + 4: error object
1959 // No Result. 1959 // No Result.
1960 void StubCode::GenerateJumpToErrorHandlerStub(Assembler* assembler) { 1960 void StubCode::GenerateJumpToErrorHandlerStub(Assembler* assembler) {
1961 __ movl(EAX, Address(ESP, 4 * kWordSize)); // Load error object. 1961 __ movl(EAX, Address(ESP, 4 * kWordSize)); // Load error object.
1962 __ movl(EBP, Address(ESP, 3 * kWordSize)); // Load target frame_pointer. 1962 __ movl(EBP, Address(ESP, 3 * kWordSize)); // Load target frame_pointer.
1963 __ movl(EBX, Address(ESP, 1 * kWordSize)); // Load target PC into EBX. 1963 __ movl(EBX, Address(ESP, 1 * kWordSize)); // Load target PC into EBX.
1964 __ movl(ESP, Address(ESP, 2 * kWordSize)); // Load target stack_pointer. 1964 __ movl(ESP, Address(ESP, 2 * kWordSize)); // Load target stack_pointer.
1965 __ jmp(EBX); // Jump to the exception handler code. 1965 __ jmp(EBX); // Jump to the exception handler code.
1966 } 1966 }
1967 1967
1968
1969 // Implements equality operator when one of the arguments is null
1970 // (identity check) and updates ICData if necessary.
1971 // TOS + 0: return address
1972 // TOS + 1: right argument
1973 // TOS + 2: left argument
1974 // ECX: ICData.
1975 // EAX: result.
1976 // TODO(srdjan): Move to VM stubs once Boolean objects become VM objects.
1977 void StubCode::GenerateEqualityWithNullArgStub(Assembler* assembler) {
1978 #if defined(DEBUG)
1979 { Label ok;
1980 __ movl(EAX, FieldAddress(ECX, ICData::num_args_tested_offset()));
1981 __ cmpl(EAX, Immediate(2));
1982 __ j(EQUAL, &ok, Assembler::kNearJump);
1983 __ Stop("Incorrect ICData for equality");
1984 __ Bind(&ok);
1985 }
1986 #endif // DEBUG
1987 // Check IC data, update if needed.
1988 // EBX: IC data object (preserved).
1989 __ movl(EBX, FieldAddress(ECX, ICData::ic_data_offset()));
1990 // EBX: ic_data_array with check entries: classes and target functions.
1991 __ leal(EBX, FieldAddress(EBX, Array::data_offset()));
1992 // EBX: points directly to the first ic data array element.
1993
1994 Label get_class_id_as_smi, no_match, loop, compute_result;
1995 __ Bind(&loop);
1996 // Check left.
1997 __ movl(EAX, Address(ESP, 2 * kWordSize));
1998 __ call(&get_class_id_as_smi);
1999 __ movl(EDI, Address(EBX, 0 * kWordSize));
2000 __ cmpl(EAX, EDI); // Class id match?
2001 __ j(NOT_EQUAL, &no_match, Assembler::kNearJump);
2002 // Check right.
2003 __ movl(EAX, Address(ESP, 1 * kWordSize));
2004 __ call(&get_class_id_as_smi);
2005 __ movl(EDI, Address(EBX, 1 * kWordSize));
2006 __ cmpl(EAX, EDI); // Class id match?
2007 __ j(EQUAL, &compute_result, Assembler::kNearJump);
2008 __ Bind(&no_match);
2009 // Each test entry has (1 + 2) array elements (2 arguments, 1 target).
2010 __ addl(EBX, Immediate(kWordSize * (1 + 2))); // Next element.
2011 __ cmpl(EDI, Immediate(Smi::RawValue(kIllegalCid))); // Done?
2012 __ j(NOT_EQUAL, &loop, Assembler::kNearJump);
2013 Label update_ic_data;
2014 __ jmp(&update_ic_data);
2015
2016 __ Bind(&compute_result);
2017 Label true_label;
2018 __ movl(EAX, Address(ESP, 1 * kWordSize));
2019 __ cmpl(EAX, Address(ESP, 2 * kWordSize));
2020 __ j(EQUAL, &true_label, Assembler::kNearJump);
2021 __ LoadObject(EAX, Bool::ZoneHandle(Bool::False()));
2022 __ ret();
2023 __ Bind(&true_label);
2024 __ LoadObject(EAX, Bool::ZoneHandle(Bool::True()));
2025 __ ret();
2026
2027 __ Bind(&get_class_id_as_smi);
2028 Label not_smi;
2029 // Test if Smi -> load Smi class for comparison.
2030 __ testl(EAX, Immediate(kSmiTagMask));
2031 __ j(NOT_ZERO, &not_smi, Assembler::kNearJump);
2032 __ movl(EAX, Immediate(Smi::RawValue(kSmiCid)));
2033 __ ret();
2034
2035 __ Bind(&not_smi);
2036 __ LoadClassId(EAX, EAX);
2037 __ SmiTag(EAX);
2038 __ ret();
2039
2040 __ Bind(&update_ic_data);
2041
2042 // ECX: ICData
2043 const String& equal_name = String::ZoneHandle(Symbols::New("=="));
2044 __ movl(EAX, Address(ESP, 1 * kWordSize));
2045 __ movl(EDI, Address(ESP, 2 * kWordSize));
2046 AssemblerMacros::EnterStubFrame(assembler);
2047 __ pushl(EDI); // arg 0
2048 __ pushl(EAX); // arg 1
2049 __ PushObject(equal_name); // Target's name.
2050 __ pushl(ECX); // ICData
2051 __ CallRuntime(kUpdateICDataTwoArgsRuntimeEntry);
2052 __ Drop(4);
2053 __ LeaveFrame();
2054
2055 __ jmp(&compute_result, Assembler::kNearJump);
2056 }
2057
2058
1968 } // namespace dart 2059 } // namespace dart
1969 2060
1970 #endif // defined TARGET_ARCH_IA32 2061 #endif // defined TARGET_ARCH_IA32
OLDNEW
« runtime/vm/object.cc ('K') | « runtime/vm/stub_code.h ('k') | runtime/vm/stub_code_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698