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

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

Issue 6062002: Merge 6006:6095 from bleeding_edge to experimental/gc branch. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/gc/
Patch Set: Created 10 years 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/ia32/full-codegen-ia32.cc ('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 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 2040 matching lines...) Expand 10 before | Expand all | Expand 10 after
2051 return greater_equal; 2051 return greater_equal;
2052 case Token::GTE: 2052 case Token::GTE:
2053 return greater_equal; 2053 return greater_equal;
2054 default: 2054 default:
2055 UNREACHABLE(); 2055 UNREACHABLE();
2056 return no_condition; 2056 return no_condition;
2057 } 2057 }
2058 } 2058 }
2059 2059
2060 2060
2061 static bool HasInlinedSmiCode(Address address) {
2062 // The address of the instruction following the call.
2063 Address test_instruction_address =
2064 address + Assembler::kCallTargetAddressOffset;
2065
2066 // If the instruction following the call is not a test al, nothing
2067 // was inlined.
2068 return *test_instruction_address == Assembler::kTestAlByte;
2069 }
2070
2071
2061 void CompareIC::UpdateCaches(Handle<Object> x, Handle<Object> y) { 2072 void CompareIC::UpdateCaches(Handle<Object> x, Handle<Object> y) {
2062 HandleScope scope; 2073 HandleScope scope;
2063 Handle<Code> rewritten; 2074 Handle<Code> rewritten;
2064 #ifdef DEBUG
2065 State previous_state = GetState(); 2075 State previous_state = GetState();
2066 #endif 2076
2067 State state = TargetState(x, y); 2077 State state = TargetState(previous_state, HasInlinedSmiCode(address()), x, y);
2068 if (state == GENERIC) { 2078 if (state == GENERIC) {
2069 CompareStub stub(GetCondition(), strict(), NO_COMPARE_FLAGS); 2079 CompareStub stub(GetCondition(), strict(), NO_COMPARE_FLAGS);
2070 rewritten = stub.GetCode(); 2080 rewritten = stub.GetCode();
2071 } else { 2081 } else {
2072 ICCompareStub stub(op_, state); 2082 ICCompareStub stub(op_, state);
2073 rewritten = stub.GetCode(); 2083 rewritten = stub.GetCode();
2074 } 2084 }
2075 set_target(*rewritten); 2085 set_target(*rewritten);
2076 2086
2077 #ifdef DEBUG 2087 #ifdef DEBUG
2078 if (FLAG_trace_ic) { 2088 if (FLAG_trace_ic) {
2079 PrintF("[CompareIC (%s->%s)#%s]\n", 2089 PrintF("[CompareIC (%s->%s)#%s]\n",
2080 GetStateName(previous_state), 2090 GetStateName(previous_state),
2081 GetStateName(state), 2091 GetStateName(state),
2082 Token::Name(op_)); 2092 Token::Name(op_));
2083 } 2093 }
2084 #endif 2094 #endif
2095
2096 // Activate inlined smi code.
2097 if (previous_state == UNINITIALIZED) {
2098 PatchInlinedSmiCode(address());
2099 }
2100 }
2101
2102
2103 void PatchInlinedSmiCode(Address address) {
2104 // The address of the instruction following the call.
2105 Address test_instruction_address =
2106 address + Assembler::kCallTargetAddressOffset;
2107
2108 // If the instruction following the call is not a test al, nothing
2109 // was inlined.
2110 if (*test_instruction_address != Assembler::kTestAlByte) {
2111 ASSERT(*test_instruction_address == Assembler::kNopByte);
2112 return;
2113 }
2114
2115 Address delta_address = test_instruction_address + 1;
2116 // The delta to the start of the map check instruction and the
2117 // condition code uses at the patched jump.
2118 int8_t delta = *reinterpret_cast<int8_t*>(delta_address);
2119 if (FLAG_trace_ic) {
2120 PrintF("[ patching ic at %p, test=%p, delta=%d\n",
2121 address, test_instruction_address, delta);
2122 }
2123
2124 // Patch with a short conditional jump. There must be a
2125 // short jump-if-carry/not-carry at this position.
2126 Address jmp_address = test_instruction_address - delta;
2127 ASSERT(*jmp_address == Assembler::kJncShortOpcode ||
2128 *jmp_address == Assembler::kJcShortOpcode);
2129 Condition cc = *jmp_address == Assembler::kJncShortOpcode
2130 ? not_zero
2131 : zero;
2132 *jmp_address = static_cast<byte>(Assembler::kJccShortPrefix | cc);
2085 } 2133 }
2086 2134
2087 2135
2088 } } // namespace v8::internal 2136 } } // namespace v8::internal
2089 2137
2090 #endif // V8_TARGET_ARCH_IA32 2138 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/full-codegen-ia32.cc ('k') | src/ia32/lithium-codegen-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698