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

Side by Side Diff: runtime/vm/stub_code_x64.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
« runtime/vm/object.cc ('K') | « runtime/vm/stub_code_ia32.cc ('k') | no next file » | 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" 5 #include "vm/globals.h"
6 #if defined(TARGET_ARCH_X64) 6 #if defined(TARGET_ARCH_X64)
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 1911 matching lines...) Expand 10 before | Expand all | Expand 10 after
1922 // RDX: frame_pointer 1922 // RDX: frame_pointer
1923 // RCX: error object 1923 // RCX: error object
1924 // No Result. 1924 // No Result.
1925 void StubCode::GenerateJumpToErrorHandlerStub(Assembler* assembler) { 1925 void StubCode::GenerateJumpToErrorHandlerStub(Assembler* assembler) {
1926 __ movq(RAX, RCX); // error object. 1926 __ movq(RAX, RCX); // error object.
1927 __ movq(RBP, RDX); // target frame_pointer. 1927 __ movq(RBP, RDX); // target frame_pointer.
1928 __ movq(RSP, RSI); // target stack_pointer. 1928 __ movq(RSP, RSI); // target stack_pointer.
1929 __ jmp(RDI); // Jump to the exception handler code. 1929 __ jmp(RDI); // Jump to the exception handler code.
1930 } 1930 }
1931 1931
1932
1933 // Implements equality operator when one of the arguments is null
1934 // (identity check) and updates ICData if necessary.
1935 // TOS + 0: return address
1936 // TOS + 1: right argument
1937 // TOS + 2: left argument
1938 // RBX: ICData.
1939 // RAX: result.
1940 // TODO(srdjan): Move to VM stubs once Boolean objects become VM objects.
1941 void StubCode::GenerateEqualityWithNullArgStub(Assembler* assembler) {
1942 #if defined(DEBUG)
1943 { Label ok;
1944 __ movq(RCX, FieldAddress(RBX, ICData::num_args_tested_offset()));
1945 __ cmpq(RCX, Immediate(2));
1946 __ j(EQUAL, &ok, Assembler::kNearJump);
1947 __ Stop("Incorrect ICData for equality");
1948 __ Bind(&ok);
1949 }
1950 #endif // DEBUG
1951 // Check IC data, update if needed.
1952 // RBX: IC data object (preserved).
1953 __ movq(R12, FieldAddress(RBX, ICData::ic_data_offset()));
1954 // R12: ic_data_array with check entries: classes and target functions.
1955 __ leaq(R12, FieldAddress(R12, Array::data_offset()));
1956 // R12: points directly to the first ic data array element.
1957
1958 Label get_class_id_as_smi, no_match, loop, compute_result;
1959 __ Bind(&loop);
1960 // Check left.
1961 __ movq(RAX, Address(RSP, 2 * kWordSize));
1962 __ call(&get_class_id_as_smi);
1963 __ movq(R13, Address(R12, 0 * kWordSize));
1964 __ cmpq(RAX, R13); // Class id match?
1965 __ j(NOT_EQUAL, &no_match, Assembler::kNearJump);
1966 // Check right.
1967 __ movq(RAX, Address(RSP, 1 * kWordSize));
1968 __ call(&get_class_id_as_smi);
1969 __ movq(R13, Address(R12, 1 * kWordSize));
1970 __ cmpq(RAX, R13); // Class id match?
1971 __ j(EQUAL, &compute_result, Assembler::kNearJump);
1972 __ Bind(&no_match);
1973 // Each test entry has (1 + 2) array elements (2 arguments, 1 target).
1974 __ addq(R12, Immediate(kWordSize * (1 + 2))); // Next element.
1975 __ cmpq(R13, Immediate(Smi::RawValue(kIllegalCid))); // Done?
1976 __ j(NOT_EQUAL, &loop, Assembler::kNearJump);
1977 Label update_ic_data;
1978 __ jmp(&update_ic_data);
1979
1980 __ Bind(&compute_result);
1981 Label true_label;
1982 __ movq(RAX, Address(RSP, 1 * kWordSize));
1983 __ cmpq(RAX, Address(RSP, 2 * kWordSize));
1984 __ j(EQUAL, &true_label, Assembler::kNearJump);
1985 __ LoadObject(RAX, Bool::ZoneHandle(Bool::False()));
1986 __ ret();
1987 __ Bind(&true_label);
1988 __ LoadObject(RAX, Bool::ZoneHandle(Bool::True()));
1989 __ ret();
1990
1991 __ Bind(&get_class_id_as_smi);
1992 Label not_smi;
1993 // Test if Smi -> load Smi class for comparison.
1994 __ testq(RAX, Immediate(kSmiTagMask));
1995 __ j(NOT_ZERO, &not_smi, Assembler::kNearJump);
1996 __ movq(RAX, Immediate(Smi::RawValue(kSmiCid)));
1997 __ ret();
1998
1999 __ Bind(&not_smi);
2000 __ LoadClassId(RAX, RAX);
2001 __ SmiTag(RAX);
2002 __ ret();
2003
2004 __ Bind(&update_ic_data);
2005
2006 // RCX: ICData
2007 const String& equal_name = String::ZoneHandle(Symbols::New("=="));
2008 __ movq(RAX, Address(RSP, 1 * kWordSize));
2009 __ movq(R13, Address(RSP, 2 * kWordSize));
2010 AssemblerMacros::EnterStubFrame(assembler);
2011 __ pushq(R13); // arg 0
2012 __ pushq(RAX); // arg 1
2013 __ PushObject(equal_name); // Target's name.
2014 __ pushq(RBX); // ICData
2015 __ CallRuntime(kUpdateICDataTwoArgsRuntimeEntry);
2016 __ Drop(4);
2017 __ LeaveFrame();
2018
2019 __ jmp(&compute_result, Assembler::kNearJump);
2020 }
2021
1932 } // namespace dart 2022 } // namespace dart
1933 2023
1934 #endif // defined TARGET_ARCH_X64 2024 #endif // defined TARGET_ARCH_X64
OLDNEW
« runtime/vm/object.cc ('K') | « runtime/vm/stub_code_ia32.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698