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

Side by Side Diff: src/code-stubs.cc

Issue 8872060: Reland 10216 - Optimize the equality check case of ICCompare stubs. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 9 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
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 int CodeStub::GetCodeKind() { 94 int CodeStub::GetCodeKind() {
95 return Code::STUB; 95 return Code::STUB;
96 } 96 }
97 97
98 98
99 Handle<Code> CodeStub::GetCode() { 99 Handle<Code> CodeStub::GetCode() {
100 Isolate* isolate = Isolate::Current(); 100 Isolate* isolate = Isolate::Current();
101 Factory* factory = isolate->factory(); 101 Factory* factory = isolate->factory();
102 Heap* heap = isolate->heap(); 102 Heap* heap = isolate->heap();
103 Code* code; 103 Code* code;
104 if (!FindCodeInCache(&code)) { 104 if (UseSpecialCache()
105 ? FindCodeInSpecialCache(&code)
106 : FindCodeInCache(&code)) {
107 ASSERT(IsPregenerated() == code->is_pregenerated());
108 return Handle<Code>(code);
109 }
110
111 {
105 HandleScope scope(isolate); 112 HandleScope scope(isolate);
106 113
107 // Generate the new code. 114 // Generate the new code.
108 MacroAssembler masm(isolate, NULL, 256); 115 MacroAssembler masm(isolate, NULL, 256);
109 GenerateCode(&masm); 116 GenerateCode(&masm);
110 117
111 // Create the code object. 118 // Create the code object.
112 CodeDesc desc; 119 CodeDesc desc;
113 masm.GetCode(&desc); 120 masm.GetCode(&desc);
114 121
115 // Copy the generated code into a heap object. 122 // Copy the generated code into a heap object.
116 Code::Flags flags = Code::ComputeFlags( 123 Code::Flags flags = Code::ComputeFlags(
117 static_cast<Code::Kind>(GetCodeKind()), 124 static_cast<Code::Kind>(GetCodeKind()),
118 GetICState()); 125 GetICState());
119 Handle<Code> new_object = factory->NewCode( 126 Handle<Code> new_object = factory->NewCode(
120 desc, flags, masm.CodeObject(), NeedsImmovableCode()); 127 desc, flags, masm.CodeObject(), NeedsImmovableCode());
121 RecordCodeGeneration(*new_object, &masm); 128 RecordCodeGeneration(*new_object, &masm);
122 FinishCode(new_object); 129 FinishCode(new_object);
123 130
124 // Update the dictionary and the root in Heap. 131 if (UseSpecialCache()) {
125 Handle<NumberDictionary> dict = 132 AddToSpecialCache(new_object);
126 factory->DictionaryAtNumberPut( 133 } else {
127 Handle<NumberDictionary>(heap->code_stubs()), 134 // Update the dictionary and the root in Heap.
128 GetKey(), 135 Handle<NumberDictionary> dict =
129 new_object); 136 factory->DictionaryAtNumberPut(
130 heap->public_set_code_stubs(*dict); 137 Handle<NumberDictionary>(heap->code_stubs()),
138 GetKey(),
139 new_object);
140 heap->public_set_code_stubs(*dict);
141 }
131 code = *new_object; 142 code = *new_object;
132 Activate(code);
133 } else {
134 CHECK(IsPregenerated() == code->is_pregenerated());
135 } 143 }
136 144
145 Activate(code);
137 ASSERT(!NeedsImmovableCode() || heap->lo_space()->Contains(code)); 146 ASSERT(!NeedsImmovableCode() || heap->lo_space()->Contains(code));
138 return Handle<Code>(code, isolate); 147 return Handle<Code>(code, isolate);
139 } 148 }
140 149
141 150
142 const char* CodeStub::MajorName(CodeStub::Major major_key, 151 const char* CodeStub::MajorName(CodeStub::Major major_key,
143 bool allow_unknown_keys) { 152 bool allow_unknown_keys) {
144 switch (major_key) { 153 switch (major_key) {
145 #define DEF_CASE(name) case name: return #name "Stub"; 154 #define DEF_CASE(name) case name: return #name "Stub";
146 CODE_STUB_LIST(DEF_CASE) 155 CODE_STUB_LIST(DEF_CASE)
147 #undef DEF_CASE 156 #undef DEF_CASE
148 default: 157 default:
149 if (!allow_unknown_keys) { 158 if (!allow_unknown_keys) {
150 UNREACHABLE(); 159 UNREACHABLE();
151 } 160 }
152 return NULL; 161 return NULL;
153 } 162 }
154 } 163 }
155 164
156 165
157 void CodeStub::PrintName(StringStream* stream) { 166 void CodeStub::PrintName(StringStream* stream) {
158 stream->Add("%s", MajorName(MajorKey(), false)); 167 stream->Add("%s", MajorName(MajorKey(), false));
159 } 168 }
160 169
161 170
171 void ICCompareStub::AddToSpecialCache(Handle<Code> new_object) {
172 ASSERT(*known_map_ != NULL);
173 Isolate* isolate = new_object->GetIsolate();
174 Factory* factory = isolate->factory();
175 return Map::UpdateCodeCache(known_map_,
176 factory->compare_ic_symbol(),
177 new_object);
178 }
179
180
181 bool ICCompareStub::FindCodeInSpecialCache(Code** code_out) {
182 Isolate* isolate = known_map_->GetIsolate();
183 Factory* factory = isolate->factory();
184 Code::Flags flags = Code::ComputeFlags(
185 static_cast<Code::Kind>(GetCodeKind()),
186 UNINITIALIZED);
187 Handle<Object> probe(
188 known_map_->FindInCodeCache(*factory->compare_ic_symbol(), flags));
189 if (probe->IsCode()) {
190 *code_out = Code::cast(*probe);
191 return true;
192 }
193 return false;
194 }
195
196
162 int ICCompareStub::MinorKey() { 197 int ICCompareStub::MinorKey() {
163 return OpField::encode(op_ - Token::EQ) | StateField::encode(state_); 198 return OpField::encode(op_ - Token::EQ) | StateField::encode(state_);
164 } 199 }
165 200
166 201
167 void ICCompareStub::Generate(MacroAssembler* masm) { 202 void ICCompareStub::Generate(MacroAssembler* masm) {
168 switch (state_) { 203 switch (state_) {
169 case CompareIC::UNINITIALIZED: 204 case CompareIC::UNINITIALIZED:
170 GenerateMiss(masm); 205 GenerateMiss(masm);
171 break; 206 break;
172 case CompareIC::SMIS: 207 case CompareIC::SMIS:
173 GenerateSmis(masm); 208 GenerateSmis(masm);
174 break; 209 break;
175 case CompareIC::HEAP_NUMBERS: 210 case CompareIC::HEAP_NUMBERS:
176 GenerateHeapNumbers(masm); 211 GenerateHeapNumbers(masm);
177 break; 212 break;
178 case CompareIC::STRINGS: 213 case CompareIC::STRINGS:
179 GenerateStrings(masm); 214 GenerateStrings(masm);
180 break; 215 break;
181 case CompareIC::SYMBOLS: 216 case CompareIC::SYMBOLS:
182 GenerateSymbols(masm); 217 GenerateSymbols(masm);
183 break; 218 break;
184 case CompareIC::OBJECTS: 219 case CompareIC::OBJECTS:
185 GenerateObjects(masm); 220 GenerateObjects(masm);
186 break; 221 break;
222 case CompareIC::KNOWN_OBJECTS:
223 ASSERT(*known_map_ != NULL);
224 GenerateKnownObjects(masm);
225 break;
187 default: 226 default:
188 UNREACHABLE(); 227 UNREACHABLE();
189 } 228 }
190 } 229 }
191 230
192 231
193 void InstanceofStub::PrintName(StringStream* stream) { 232 void InstanceofStub::PrintName(StringStream* stream) {
194 const char* args = ""; 233 const char* args = "";
195 if (HasArgsInRegisters()) { 234 if (HasArgsInRegisters()) {
196 args = "_REGS"; 235 args = "_REGS";
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 KeyedStoreStubCompiler::GenerateStoreFastDoubleElement(masm, is_jsarray_); 440 KeyedStoreStubCompiler::GenerateStoreFastDoubleElement(masm, is_jsarray_);
402 } else { 441 } else {
403 UNREACHABLE(); 442 UNREACHABLE();
404 } 443 }
405 } 444 }
406 masm->bind(&fail); 445 masm->bind(&fail);
407 KeyedStoreIC::GenerateRuntimeSetProperty(masm, strict_mode_); 446 KeyedStoreIC::GenerateRuntimeSetProperty(masm, strict_mode_);
408 } 447 }
409 448
410 } } // namespace v8::internal 449 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698