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

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: Final 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
« no previous file with comments | « src/code-stubs.h ('k') | src/flag-definitions.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 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 LChunk* chunk = OptimizeGraph(builder.CreateGraph()); 222 LChunk* chunk = OptimizeGraph(builder.CreateGraph());
221 return chunk->Codegen(Code::COMPILED_STUB); 223 return chunk->Codegen(Code::COMPILED_STUB);
222 } 224 }
223 225
224 226
225 template <> 227 template <>
226 HValue* CodeStubGraphBuilder<KeyedLoadFastElementStub>::BuildCodeStub() { 228 HValue* CodeStubGraphBuilder<KeyedLoadFastElementStub>::BuildCodeStub() {
227 HInstruction* load = BuildUncheckedMonomorphicElementAccess( 229 HInstruction* load = BuildUncheckedMonomorphicElementAccess(
228 GetParameter(0), GetParameter(1), NULL, NULL, 230 GetParameter(0), GetParameter(1), NULL, NULL,
229 casted_stub()->is_js_array(), casted_stub()->elements_kind(), 231 casted_stub()->is_js_array(), casted_stub()->elements_kind(),
230 false, Representation::Tagged()); 232 false, STANDARD_STORE, Representation::Tagged());
231 AddInstruction(load);
232 return load; 233 return load;
233 } 234 }
234 235
235 236
236 Handle<Code> KeyedLoadFastElementStub::GenerateCode() { 237 Handle<Code> KeyedLoadFastElementStub::GenerateCode() {
237 CodeStubGraphBuilder<KeyedLoadFastElementStub> builder(this); 238 CodeStubGraphBuilder<KeyedLoadFastElementStub> builder(this);
238 LChunk* chunk = OptimizeGraph(builder.CreateGraph()); 239 LChunk* chunk = OptimizeGraph(builder.CreateGraph());
239 return chunk->Codegen(Code::COMPILED_STUB); 240 return chunk->Codegen(Code::COMPILED_STUB);
240 } 241 }
241 242
242 243
243 template <> 244 template <>
245 HValue* CodeStubGraphBuilder<KeyedStoreFastElementStub>::BuildCodeStub() {
246 BuildUncheckedMonomorphicElementAccess(
247 GetParameter(0), GetParameter(1), GetParameter(2), NULL,
248 casted_stub()->is_js_array(), casted_stub()->elements_kind(),
249 true, casted_stub()->store_mode(), Representation::Tagged());
250 AddSimulate(BailoutId::StubEntry(), REMOVABLE_SIMULATE);
251
252 return GetParameter(2);
253 }
254
255
256 Handle<Code> KeyedStoreFastElementStub::GenerateCode() {
257 CodeStubGraphBuilder<KeyedStoreFastElementStub> builder(this);
258 LChunk* chunk = OptimizeGraph(builder.CreateGraph());
259 return chunk->Codegen(Code::COMPILED_STUB);
260 }
261
262
263 template <>
244 HValue* CodeStubGraphBuilder<TransitionElementsKindStub>::BuildCodeStub() { 264 HValue* CodeStubGraphBuilder<TransitionElementsKindStub>::BuildCodeStub() {
245 Zone* zone = this->zone(); 265 Zone* zone = this->zone();
246 266
247 HValue* js_array = GetParameter(0); 267 HValue* js_array = GetParameter(0);
248 HValue* map = GetParameter(1); 268 HValue* map = GetParameter(1);
249 269
250 info()->MarkAsSavesCallerDoubles(); 270 info()->MarkAsSavesCallerDoubles();
251 271
252 AddInstruction(new(zone) HTrapAllocationMemento(js_array)); 272 AddInstruction(new(zone) HTrapAllocationMemento(js_array));
253 273
254 HInstruction* array_length = 274 HInstruction* array_length =
255 AddInstruction(new(zone) HJSArrayLength(js_array, 275 AddInstruction(new(zone) HJSArrayLength(js_array,
256 js_array, 276 js_array,
257 HType::Smi())); 277 HType::Smi()));
258 278
259 Heap* heap = isolate()->heap(); 279 ElementsKind to_kind = casted_stub()->to_kind();
260 const int kMinFreeNewSpaceAfterGC = 280 BuildNewSpaceArrayCheck(array_length, to_kind);
261 ((heap->InitialSemiSpaceSize() - sizeof(FixedArrayBase)) / 2) /
262 kDoubleSize;
263
264 HConstant* max_alloc_size =
265 new(zone) HConstant(kMinFreeNewSpaceAfterGC, Representation::Integer32());
266 AddInstruction(max_alloc_size);
267 // Since we're forcing Integer32 representation for this HBoundsCheck,
268 // there's no need to Smi-check the index.
269 AddInstruction(
270 new(zone) HBoundsCheck(array_length, max_alloc_size,
271 DONT_ALLOW_SMI_KEY, Representation::Integer32()));
272 281
273 IfBuilder if_builder(this, BailoutId::StubEntry()); 282 IfBuilder if_builder(this, BailoutId::StubEntry());
274 283
275 if_builder.BeginTrue(array_length, graph()->GetConstant0(), Token::EQ); 284 if_builder.BeginIf(array_length, graph()->GetConstant0(), Token::EQ);
276 285
277 // Nothing to do, just change the map. 286 // Nothing to do, just change the map.
278 287
279 if_builder.BeginFalse(); 288 if_builder.BeginElse();
280 289
281 HInstruction* elements = 290 HInstruction* elements =
282 AddInstruction(new(zone) HLoadElements(js_array, js_array)); 291 AddInstruction(new(zone) HLoadElements(js_array, js_array));
283 292
284 HInstruction* elements_length = 293 HInstruction* elements_length =
285 AddInstruction(new(zone) HFixedArrayBaseLength(elements)); 294 AddInstruction(new(zone) HFixedArrayBaseLength(elements));
286 295
287 ElementsKind to_kind = casted_stub()->to_kind();
288 HValue* new_elements = 296 HValue* new_elements =
289 BuildAllocateElements(context(), to_kind, elements_length); 297 BuildAllocateElements(context(), to_kind, elements_length,
290 298 BailoutId::StubEntry());
291 // Fast elements kinds need to be initialized in case statements below cause a
292 // garbage collection.
293 Factory* factory = isolate()->factory();
294
295 ASSERT(!IsFastSmiElementsKind(to_kind));
296 double nan_double = FixedDoubleArray::hole_nan_as_double();
297 HValue* hole = IsFastObjectElementsKind(to_kind)
298 ? AddInstruction(new(zone) HConstant(factory->the_hole_value(),
299 Representation::Tagged()))
300 : AddInstruction(new(zone) HConstant(nan_double,
301 Representation::Double()));
302
303 LoopBuilder builder(this, context(), LoopBuilder::kPostIncrement,
304 BailoutId::StubEntry());
305
306 HValue* zero = graph()->GetConstant0();
307 HValue* start = IsFastElementsKind(to_kind) ? zero : array_length;
308 HValue* key = builder.BeginBody(start, elements_length, Token::LT);
309
310 AddInstruction(new(zone) HStoreKeyed(new_elements, key, hole, to_kind));
311 AddSimulate(BailoutId::StubEntry(), REMOVABLE_SIMULATE);
312
313 builder.EndBody();
314 299
315 BuildCopyElements(context(), elements, 300 BuildCopyElements(context(), elements,
316 casted_stub()->from_kind(), new_elements, 301 casted_stub()->from_kind(), new_elements,
317 to_kind, array_length); 302 to_kind, array_length, elements_length,
303 BailoutId::StubEntry());
304
305 Factory* factory = isolate()->factory();
318 306
319 AddInstruction(new(zone) HStoreNamedField(js_array, 307 AddInstruction(new(zone) HStoreNamedField(js_array,
320 factory->elements_field_string(), 308 factory->elements_field_string(),
321 new_elements, true, 309 new_elements, true,
322 JSArray::kElementsOffset)); 310 JSArray::kElementsOffset));
323 AddSimulate(BailoutId::StubEntry()); 311 AddSimulate(BailoutId::StubEntry());
324 312
325 if_builder.End(); 313 if_builder.End();
326 314
327 AddInstruction(new(zone) HStoreNamedField(js_array, factory->length_string(), 315 AddInstruction(new(zone) HStoreNamedField(js_array, factory->length_string(),
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 } 368 }
381 369
382 370
383 Handle<Code> ArrayNArgumentsConstructorStub::GenerateCode() { 371 Handle<Code> ArrayNArgumentsConstructorStub::GenerateCode() {
384 CodeStubGraphBuilder<ArrayNArgumentsConstructorStub> builder(this); 372 CodeStubGraphBuilder<ArrayNArgumentsConstructorStub> builder(this);
385 LChunk* chunk = OptimizeGraph(builder.CreateGraph()); 373 LChunk* chunk = OptimizeGraph(builder.CreateGraph());
386 return chunk->Codegen(Code::COMPILED_STUB); 374 return chunk->Codegen(Code::COMPILED_STUB);
387 } 375 }
388 376
389 } } // namespace v8::internal 377 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/code-stubs.h ('k') | src/flag-definitions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698