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

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

Issue 12221064: Implement many KeyedStoreStubs using Crankshaft (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebase Created 7 years, 9 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 | « src/code-stubs.cc ('k') | src/heap.h » ('j') | src/hydrogen.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 93
94 Zone* zone = this->zone(); 94 Zone* zone = this->zone();
95 HEnvironment* start_environment = 95 HEnvironment* start_environment =
96 new(zone) HEnvironment(zone, descriptor_->register_param_count_); 96 new(zone) HEnvironment(zone, descriptor_->register_param_count_);
97 HBasicBlock* next_block = CreateBasicBlock(start_environment); 97 HBasicBlock* next_block = CreateBasicBlock(start_environment);
98 98
99 current_block()->Goto(next_block); 99 current_block()->Goto(next_block);
100 next_block->SetJoinId(BailoutId::StubEntry()); 100 next_block->SetJoinId(BailoutId::StubEntry());
101 set_current_block(next_block); 101 set_current_block(next_block);
102 102
103 start_environment->set_ast_id(BailoutId::StubEntry());
104
103 HConstant* undefined_constant = new(zone) HConstant( 105 HConstant* undefined_constant = new(zone) HConstant(
104 isolate()->factory()->undefined_value(), Representation::Tagged()); 106 isolate()->factory()->undefined_value(), Representation::Tagged());
105 AddInstruction(undefined_constant); 107 AddInstruction(undefined_constant);
106 graph()->set_undefined_constant(undefined_constant); 108 graph()->set_undefined_constant(undefined_constant);
107 109
108 int param_count = descriptor_->register_param_count_; 110 int param_count = descriptor_->register_param_count_;
109 for (int i = 0; i < param_count; ++i) { 111 for (int i = 0; i < param_count; ++i) {
110 HParameter* param = 112 HParameter* param =
111 new(zone) HParameter(i, HParameter::REGISTER_PARAMETER); 113 new(zone) HParameter(i, HParameter::REGISTER_PARAMETER);
112 AddInstruction(param); 114 AddInstruction(param);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 } 193 }
192 194
193 195
194 template <> 196 template <>
195 void CodeStubGraphBuilder<KeyedLoadFastElementStub>::BuildCodeStub() { 197 void CodeStubGraphBuilder<KeyedLoadFastElementStub>::BuildCodeStub() {
196 Zone* zone = this->zone(); 198 Zone* zone = this->zone();
197 199
198 HInstruction* load = BuildUncheckedMonomorphicElementAccess( 200 HInstruction* load = BuildUncheckedMonomorphicElementAccess(
199 GetParameter(0), GetParameter(1), NULL, NULL, 201 GetParameter(0), GetParameter(1), NULL, NULL,
200 casted_stub()->is_js_array(), casted_stub()->elements_kind(), 202 casted_stub()->is_js_array(), casted_stub()->elements_kind(),
201 false, Representation::Tagged()); 203 false, STANDARD_STORE, Representation::Tagged());
202 AddInstruction(load);
203 204
204 HReturn* ret = new(zone) HReturn(load, context()); 205 HReturn* ret = new(zone) HReturn(load, context());
205 current_block()->Finish(ret); 206 current_block()->Finish(ret);
206 } 207 }
207 208
208 209
209 Handle<Code> KeyedLoadFastElementStub::GenerateCode() { 210 Handle<Code> KeyedLoadFastElementStub::GenerateCode() {
210 CodeStubGraphBuilder<KeyedLoadFastElementStub> builder(this); 211 CodeStubGraphBuilder<KeyedLoadFastElementStub> builder(this);
211 LChunk* chunk = OptimizeGraph(builder.CreateGraph()); 212 LChunk* chunk = OptimizeGraph(builder.CreateGraph());
212 return chunk->Codegen(Code::COMPILED_STUB); 213 return chunk->Codegen(Code::COMPILED_STUB);
213 } 214 }
214 215
215 216
216 template <> 217 template <>
218 void CodeStubGraphBuilder<KeyedStoreFastElementStub>::BuildCodeStub() {
219 Zone* zone = this->zone();
220
221 BuildUncheckedMonomorphicElementAccess(
222 GetParameter(0), GetParameter(1), GetParameter(2), NULL,
223 casted_stub()->is_js_array(), casted_stub()->elements_kind(),
224 true, casted_stub()->store_mode(), Representation::Tagged());
225 AddSimulate(BailoutId::StubEntry(), REMOVABLE_SIMULATE);
226
227 HReturn* ret = new(zone) HReturn(GetParameter(2), context());
228 current_block()->Finish(ret);
229 }
230
231
232 Handle<Code> KeyedStoreFastElementStub::GenerateCode() {
233 CodeStubGraphBuilder<KeyedStoreFastElementStub> builder(this);
234 LChunk* chunk = OptimizeGraph(builder.CreateGraph());
235 return chunk->Codegen(Code::COMPILED_STUB);
236 }
237
238
239 template <>
217 void CodeStubGraphBuilder<TransitionElementsKindStub>::BuildCodeStub() { 240 void CodeStubGraphBuilder<TransitionElementsKindStub>::BuildCodeStub() {
218 Zone* zone = this->zone(); 241 Zone* zone = this->zone();
219 242
220 HValue* js_array = GetParameter(0); 243 HValue* js_array = GetParameter(0);
221 HValue* map = GetParameter(1); 244 HValue* map = GetParameter(1);
222 245
223 info()->MarkAsSavesCallerDoubles(); 246 info()->MarkAsSavesCallerDoubles();
224 247
225 AddInstruction(new(zone) HTrapAllocationMemento(js_array)); 248 AddInstruction(new(zone) HTrapAllocationMemento(js_array));
226 249
227 HInstruction* array_length = 250 HInstruction* array_length =
228 AddInstruction(new(zone) HJSArrayLength(js_array, 251 AddInstruction(new(zone) HJSArrayLength(js_array,
229 js_array, 252 js_array,
230 HType::Smi())); 253 HType::Smi()));
231 254
232 Heap* heap = isolate()->heap(); 255 ElementsKind to_kind = casted_stub()->to_kind();
233 const int kMinFreeNewSpaceAfterGC = 256 BuildNewSpaceArrayCheck(array_length, to_kind);
234 ((heap->InitialSemiSpaceSize() - sizeof(FixedArrayBase)) / 2) /
235 kDoubleSize;
236
237 HConstant* max_alloc_size =
238 new(zone) HConstant(kMinFreeNewSpaceAfterGC, Representation::Integer32());
239 AddInstruction(max_alloc_size);
240 // Since we're forcing Integer32 representation for this HBoundsCheck,
241 // there's no need to Smi-check the index.
242 AddInstruction(
243 new(zone) HBoundsCheck(array_length, max_alloc_size,
244 DONT_ALLOW_SMI_KEY, Representation::Integer32()));
245 257
246 IfBuilder if_builder(this, BailoutId::StubEntry()); 258 IfBuilder if_builder(this, BailoutId::StubEntry());
247 259
248 if_builder.BeginTrue(array_length, graph()->GetConstant0(), Token::EQ); 260 if_builder.BeginIf(array_length, graph()->GetConstant0(), Token::EQ);
249 261
250 // Nothing to do, just change the map. 262 // Nothing to do, just change the map.
251 263
252 if_builder.BeginFalse(); 264 if_builder.BeginElse();
253 265
254 HInstruction* elements = 266 HInstruction* elements =
255 AddInstruction(new(zone) HLoadElements(js_array, js_array)); 267 AddInstruction(new(zone) HLoadElements(js_array, js_array));
256 268
257 HInstruction* elements_length = 269 HInstruction* elements_length =
258 AddInstruction(new(zone) HFixedArrayBaseLength(elements)); 270 AddInstruction(new(zone) HFixedArrayBaseLength(elements));
259 271
260 ElementsKind to_kind = casted_stub()->to_kind();
261 HValue* new_elements = 272 HValue* new_elements =
262 BuildAllocateElements(context(), to_kind, elements_length); 273 BuildAllocateElements(context(), to_kind, elements_length,
263 274 BailoutId::StubEntry());
264 // Fast elements kinds need to be initialized in case statements below cause a
265 // garbage collection.
266 Factory* factory = isolate()->factory();
267
268 ASSERT(!IsFastSmiElementsKind(to_kind));
269 double nan_double = FixedDoubleArray::hole_nan_as_double();
270 HValue* hole = IsFastObjectElementsKind(to_kind)
271 ? AddInstruction(new(zone) HConstant(factory->the_hole_value(),
272 Representation::Tagged()))
273 : AddInstruction(new(zone) HConstant(nan_double,
274 Representation::Double()));
275
276 LoopBuilder builder(this, context(), LoopBuilder::kPostIncrement,
277 BailoutId::StubEntry());
278
279 HValue* zero = graph()->GetConstant0();
280 HValue* start = IsFastElementsKind(to_kind) ? zero : array_length;
281 HValue* key = builder.BeginBody(start, elements_length, Token::LT);
282
283 AddInstruction(new(zone) HStoreKeyed(new_elements, key, hole, to_kind));
284 AddSimulate(BailoutId::StubEntry(), REMOVABLE_SIMULATE);
285
286 builder.EndBody();
287 275
288 BuildCopyElements(context(), elements, 276 BuildCopyElements(context(), elements,
289 casted_stub()->from_kind(), new_elements, 277 casted_stub()->from_kind(), new_elements,
290 to_kind, array_length); 278 to_kind, array_length, elements_length,
279 BailoutId::StubEntry());
280
281 Isolate* isolate = graph()->isolate();
Jakob Kummerow 2013/03/11 16:36:07 not necessary, can use [this->]isolate() directly
danno 2013/03/13 15:36:26 Done.
282 Factory* factory = isolate->factory();
291 283
292 AddInstruction(new(zone) HStoreNamedField(js_array, 284 AddInstruction(new(zone) HStoreNamedField(js_array,
293 factory->elements_field_string(), 285 factory->elements_field_string(),
294 new_elements, true, 286 new_elements, true,
295 JSArray::kElementsOffset)); 287 JSArray::kElementsOffset));
296 AddSimulate(BailoutId::StubEntry()); 288 AddSimulate(BailoutId::StubEntry());
297 289
298 if_builder.End(); 290 if_builder.End();
299 291
300 AddInstruction(new(zone) HStoreNamedField(js_array, factory->length_string(), 292 AddInstruction(new(zone) HStoreNamedField(js_array, factory->length_string(),
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 } 349 }
358 350
359 351
360 Handle<Code> ArrayNArgumentsConstructorStub::GenerateCode() { 352 Handle<Code> ArrayNArgumentsConstructorStub::GenerateCode() {
361 CodeStubGraphBuilder<ArrayNArgumentsConstructorStub> builder(this); 353 CodeStubGraphBuilder<ArrayNArgumentsConstructorStub> builder(this);
362 LChunk* chunk = OptimizeGraph(builder.CreateGraph()); 354 LChunk* chunk = OptimizeGraph(builder.CreateGraph());
363 return chunk->Codegen(Code::COMPILED_STUB); 355 return chunk->Codegen(Code::COMPILED_STUB);
364 } 356 }
365 357
366 } } // namespace v8::internal 358 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/code-stubs.cc ('k') | src/heap.h » ('j') | src/hydrogen.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698