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

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: Add runtime flag and address review feedback 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
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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 } 104 }
105 105
106 Zone* zone = this->zone(); 106 Zone* zone = this->zone();
107 int param_count = descriptor_->register_param_count_; 107 int param_count = descriptor_->register_param_count_;
108 HEnvironment* start_environment = graph()->start_environment(); 108 HEnvironment* start_environment = graph()->start_environment();
109 HBasicBlock* next_block = CreateBasicBlock(start_environment); 109 HBasicBlock* next_block = CreateBasicBlock(start_environment);
110 current_block()->Goto(next_block); 110 current_block()->Goto(next_block);
111 next_block->SetJoinId(BailoutId::StubEntry()); 111 next_block->SetJoinId(BailoutId::StubEntry());
112 set_current_block(next_block); 112 set_current_block(next_block);
113 113
114 start_environment->set_ast_id(BailoutId::StubEntry());
115
114 HConstant* undefined_constant = new(zone) HConstant( 116 HConstant* undefined_constant = new(zone) HConstant(
115 isolate()->factory()->undefined_value(), Representation::Tagged()); 117 isolate()->factory()->undefined_value(), Representation::Tagged());
116 AddInstruction(undefined_constant); 118 AddInstruction(undefined_constant);
117 graph()->set_undefined_constant(undefined_constant); 119 graph()->set_undefined_constant(undefined_constant);
118 120
119 for (int i = 0; i < param_count; ++i) { 121 for (int i = 0; i < param_count; ++i) {
120 HParameter* param = 122 HParameter* param =
121 new(zone) HParameter(i, HParameter::REGISTER_PARAMETER); 123 new(zone) HParameter(i, HParameter::REGISTER_PARAMETER);
122 AddInstruction(param); 124 AddInstruction(param);
123 start_environment->Bind(i, param); 125 start_environment->Bind(i, param);
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 LChunk* chunk = OptimizeGraph(builder.CreateGraph()); 217 LChunk* chunk = OptimizeGraph(builder.CreateGraph());
216 return chunk->Codegen(Code::COMPILED_STUB); 218 return chunk->Codegen(Code::COMPILED_STUB);
217 } 219 }
218 220
219 221
220 template <> 222 template <>
221 HValue* CodeStubGraphBuilder<KeyedLoadFastElementStub>::BuildCodeStub() { 223 HValue* CodeStubGraphBuilder<KeyedLoadFastElementStub>::BuildCodeStub() {
222 HInstruction* load = BuildUncheckedMonomorphicElementAccess( 224 HInstruction* load = BuildUncheckedMonomorphicElementAccess(
223 GetParameter(0), GetParameter(1), NULL, NULL, 225 GetParameter(0), GetParameter(1), NULL, NULL,
224 casted_stub()->is_js_array(), casted_stub()->elements_kind(), 226 casted_stub()->is_js_array(), casted_stub()->elements_kind(),
225 false, Representation::Tagged()); 227 false, STANDARD_STORE, Representation::Tagged());
226 AddInstruction(load);
227 return load; 228 return load;
228 } 229 }
229 230
230 231
231 Handle<Code> KeyedLoadFastElementStub::GenerateCode() { 232 Handle<Code> KeyedLoadFastElementStub::GenerateCode() {
232 CodeStubGraphBuilder<KeyedLoadFastElementStub> builder(this); 233 CodeStubGraphBuilder<KeyedLoadFastElementStub> builder(this);
233 LChunk* chunk = OptimizeGraph(builder.CreateGraph()); 234 LChunk* chunk = OptimizeGraph(builder.CreateGraph());
234 return chunk->Codegen(Code::COMPILED_STUB); 235 return chunk->Codegen(Code::COMPILED_STUB);
235 } 236 }
236 237
237 238
238 template <> 239 template <>
240 HValue* CodeStubGraphBuilder<KeyedStoreFastElementStub>::BuildCodeStub() {
241 BuildUncheckedMonomorphicElementAccess(
242 GetParameter(0), GetParameter(1), GetParameter(2), NULL,
243 casted_stub()->is_js_array(), casted_stub()->elements_kind(),
244 true, casted_stub()->store_mode(), Representation::Tagged());
245 AddSimulate(BailoutId::StubEntry(), REMOVABLE_SIMULATE);
246
247 return GetParameter(2);
248 }
249
250
251 Handle<Code> KeyedStoreFastElementStub::GenerateCode() {
252 CodeStubGraphBuilder<KeyedStoreFastElementStub> builder(this);
253 LChunk* chunk = OptimizeGraph(builder.CreateGraph());
254 return chunk->Codegen(Code::COMPILED_STUB);
255 }
256
257
258 template <>
239 HValue* CodeStubGraphBuilder<TransitionElementsKindStub>::BuildCodeStub() { 259 HValue* CodeStubGraphBuilder<TransitionElementsKindStub>::BuildCodeStub() {
240 Zone* zone = this->zone(); 260 Zone* zone = this->zone();
241 261
242 HValue* js_array = GetParameter(0); 262 HValue* js_array = GetParameter(0);
243 HValue* map = GetParameter(1); 263 HValue* map = GetParameter(1);
244 264
245 info()->MarkAsSavesCallerDoubles(); 265 info()->MarkAsSavesCallerDoubles();
246 266
247 AddInstruction(new(zone) HTrapAllocationMemento(js_array)); 267 AddInstruction(new(zone) HTrapAllocationMemento(js_array));
248 268
249 HInstruction* array_length = 269 HInstruction* array_length =
250 AddInstruction(new(zone) HJSArrayLength(js_array, 270 AddInstruction(new(zone) HJSArrayLength(js_array,
251 js_array, 271 js_array,
252 HType::Smi())); 272 HType::Smi()));
253 273
254 Heap* heap = isolate()->heap(); 274 ElementsKind to_kind = casted_stub()->to_kind();
255 const int kMinFreeNewSpaceAfterGC = 275 BuildNewSpaceArrayCheck(array_length, to_kind);
256 ((heap->InitialSemiSpaceSize() - sizeof(FixedArrayBase)) / 2) /
257 kDoubleSize;
258
259 HConstant* max_alloc_size =
260 new(zone) HConstant(kMinFreeNewSpaceAfterGC, Representation::Integer32());
261 AddInstruction(max_alloc_size);
262 // Since we're forcing Integer32 representation for this HBoundsCheck,
263 // there's no need to Smi-check the index.
264 AddInstruction(
265 new(zone) HBoundsCheck(array_length, max_alloc_size,
266 DONT_ALLOW_SMI_KEY, Representation::Integer32()));
267 276
268 IfBuilder if_builder(this, BailoutId::StubEntry()); 277 IfBuilder if_builder(this, BailoutId::StubEntry());
269 278
270 if_builder.BeginTrue(array_length, graph()->GetConstant0(), Token::EQ); 279 if_builder.BeginIf(array_length, graph()->GetConstant0(), Token::EQ);
271 280
272 // Nothing to do, just change the map. 281 // Nothing to do, just change the map.
273 282
274 if_builder.BeginFalse(); 283 if_builder.BeginElse();
275 284
276 HInstruction* elements = 285 HInstruction* elements =
277 AddInstruction(new(zone) HLoadElements(js_array, js_array)); 286 AddInstruction(new(zone) HLoadElements(js_array, js_array));
278 287
279 HInstruction* elements_length = 288 HInstruction* elements_length =
280 AddInstruction(new(zone) HFixedArrayBaseLength(elements)); 289 AddInstruction(new(zone) HFixedArrayBaseLength(elements));
281 290
282 ElementsKind to_kind = casted_stub()->to_kind();
283 HValue* new_elements = 291 HValue* new_elements =
284 BuildAllocateElements(context(), to_kind, elements_length); 292 BuildAllocateElements(context(), to_kind, elements_length,
285 293 BailoutId::StubEntry());
286 // Fast elements kinds need to be initialized in case statements below cause a
287 // garbage collection.
288 Factory* factory = isolate()->factory();
289
290 ASSERT(!IsFastSmiElementsKind(to_kind));
291 double nan_double = FixedDoubleArray::hole_nan_as_double();
292 HValue* hole = IsFastObjectElementsKind(to_kind)
293 ? AddInstruction(new(zone) HConstant(factory->the_hole_value(),
294 Representation::Tagged()))
295 : AddInstruction(new(zone) HConstant(nan_double,
296 Representation::Double()));
297
298 LoopBuilder builder(this, context(), LoopBuilder::kPostIncrement,
299 BailoutId::StubEntry());
300
301 HValue* zero = graph()->GetConstant0();
302 HValue* start = IsFastElementsKind(to_kind) ? zero : array_length;
303 HValue* key = builder.BeginBody(start, elements_length, Token::LT);
304
305 AddInstruction(new(zone) HStoreKeyed(new_elements, key, hole, to_kind));
306 AddSimulate(BailoutId::StubEntry(), REMOVABLE_SIMULATE);
307
308 builder.EndBody();
309 294
310 BuildCopyElements(context(), elements, 295 BuildCopyElements(context(), elements,
311 casted_stub()->from_kind(), new_elements, 296 casted_stub()->from_kind(), new_elements,
312 to_kind, array_length); 297 to_kind, array_length, elements_length,
298 BailoutId::StubEntry());
299
300 Factory* factory = isolate()->factory();
313 301
314 AddInstruction(new(zone) HStoreNamedField(js_array, 302 AddInstruction(new(zone) HStoreNamedField(js_array,
315 factory->elements_field_string(), 303 factory->elements_field_string(),
316 new_elements, true, 304 new_elements, true,
317 JSArray::kElementsOffset)); 305 JSArray::kElementsOffset));
318 AddSimulate(BailoutId::StubEntry()); 306 AddSimulate(BailoutId::StubEntry());
319 307
320 if_builder.End(); 308 if_builder.End();
321 309
322 AddInstruction(new(zone) HStoreNamedField(js_array, factory->length_string(), 310 AddInstruction(new(zone) HStoreNamedField(js_array, factory->length_string(),
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 } 363 }
376 364
377 365
378 Handle<Code> ArrayNArgumentsConstructorStub::GenerateCode() { 366 Handle<Code> ArrayNArgumentsConstructorStub::GenerateCode() {
379 CodeStubGraphBuilder<ArrayNArgumentsConstructorStub> builder(this); 367 CodeStubGraphBuilder<ArrayNArgumentsConstructorStub> builder(this);
380 LChunk* chunk = OptimizeGraph(builder.CreateGraph()); 368 LChunk* chunk = OptimizeGraph(builder.CreateGraph());
381 return chunk->Codegen(Code::COMPILED_STUB); 369 return chunk->Codegen(Code::COMPILED_STUB);
382 } 370 }
383 371
384 } } // namespace v8::internal 372 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698