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

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

Issue 257563004: Unify and simplify the FastCloneShallowArrayStub (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Review feedback Created 6 years, 7 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/hydrogen.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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 int param_count = descriptor_->register_param_count_; 143 int param_count = descriptor_->register_param_count_;
144 HEnvironment* start_environment = graph()->start_environment(); 144 HEnvironment* start_environment = graph()->start_environment();
145 HBasicBlock* next_block = CreateBasicBlock(start_environment); 145 HBasicBlock* next_block = CreateBasicBlock(start_environment);
146 Goto(next_block); 146 Goto(next_block);
147 next_block->SetJoinId(BailoutId::StubEntry()); 147 next_block->SetJoinId(BailoutId::StubEntry());
148 set_current_block(next_block); 148 set_current_block(next_block);
149 149
150 bool runtime_stack_params = descriptor_->stack_parameter_count_.is_valid(); 150 bool runtime_stack_params = descriptor_->stack_parameter_count_.is_valid();
151 HInstruction* stack_parameter_count = NULL; 151 HInstruction* stack_parameter_count = NULL;
152 for (int i = 0; i < param_count; ++i) { 152 for (int i = 0; i < param_count; ++i) {
153 Representation r = descriptor_->IsParameterCountRegister(i) 153 Representation r = descriptor_->register_param_representations_ == NULL
154 ? Representation::Integer32() 154 ? Representation::Tagged()
155 : Representation::Tagged(); 155 : descriptor_->register_param_representations_[i];
156 HParameter* param = Add<HParameter>(i, HParameter::REGISTER_PARAMETER, r); 156 HParameter* param = Add<HParameter>(i, HParameter::REGISTER_PARAMETER, r);
157 start_environment->Bind(i, param); 157 start_environment->Bind(i, param);
158 parameters_[i] = param; 158 parameters_[i] = param;
159 if (descriptor_->IsParameterCountRegister(i)) { 159 if (descriptor_->IsParameterCountRegister(i)) {
160 param->set_type(HType::Smi()); 160 param->set_type(HType::Smi());
161 stack_parameter_count = param; 161 stack_parameter_count = param;
162 arguments_length_ = stack_parameter_count; 162 arguments_length_ = stack_parameter_count;
163 } 163 }
164 } 164 }
165 165
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 Handle<Code> NumberToStringStub::GenerateCode() { 346 Handle<Code> NumberToStringStub::GenerateCode() {
347 return DoGenerateCode(this); 347 return DoGenerateCode(this);
348 } 348 }
349 349
350 350
351 template <> 351 template <>
352 HValue* CodeStubGraphBuilder<FastCloneShallowArrayStub>::BuildCodeStub() { 352 HValue* CodeStubGraphBuilder<FastCloneShallowArrayStub>::BuildCodeStub() {
353 Factory* factory = isolate()->factory(); 353 Factory* factory = isolate()->factory();
354 HValue* undefined = graph()->GetConstantUndefined(); 354 HValue* undefined = graph()->GetConstantUndefined();
355 AllocationSiteMode alloc_site_mode = casted_stub()->allocation_site_mode(); 355 AllocationSiteMode alloc_site_mode = casted_stub()->allocation_site_mode();
356 FastCloneShallowArrayStub::Mode mode = casted_stub()->mode();
357 int length = casted_stub()->length();
358 356
359 HInstruction* allocation_site = Add<HLoadKeyed>(GetParameter(0), 357 HInstruction* allocation_site = Add<HLoadKeyed>(GetParameter(0),
360 GetParameter(1), 358 GetParameter(1),
361 static_cast<HValue*>(NULL), 359 static_cast<HValue*>(NULL),
362 FAST_ELEMENTS); 360 FAST_ELEMENTS);
363 IfBuilder checker(this); 361 IfBuilder checker(this);
364 checker.IfNot<HCompareObjectEqAndBranch, HValue*>(allocation_site, 362 checker.IfNot<HCompareObjectEqAndBranch, HValue*>(allocation_site,
365 undefined); 363 undefined);
366 checker.Then(); 364 checker.Then();
367 365
368 HObjectAccess access = HObjectAccess::ForAllocationSiteOffset( 366 HObjectAccess access = HObjectAccess::ForAllocationSiteOffset(
369 AllocationSite::kTransitionInfoOffset); 367 AllocationSite::kTransitionInfoOffset);
370 HInstruction* boilerplate = Add<HLoadNamedField>( 368 HInstruction* boilerplate = Add<HLoadNamedField>(
371 allocation_site, static_cast<HValue*>(NULL), access); 369 allocation_site, static_cast<HValue*>(NULL), access);
372 HValue* push_value; 370 HValue* elements = AddLoadElements(boilerplate);
373 if (mode == FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS) { 371 HValue* capacity = AddLoadFixedArrayLength(elements);
374 HValue* elements = AddLoadElements(boilerplate); 372 IfBuilder zero_capacity(this);
373 zero_capacity.If<HCompareNumericAndBranch>(capacity, graph()->GetConstant0(),
374 Token::EQ);
375 zero_capacity.Then();
376 Push(BuildCloneShallowArrayEmpty(boilerplate,
377 allocation_site,
378 alloc_site_mode));
379 zero_capacity.Else();
380 IfBuilder if_fixed_cow(this);
381 if_fixed_cow.If<HCompareMap>(elements, factory->fixed_cow_array_map());
382 if_fixed_cow.Then();
383 Push(BuildCloneShallowArrayCow(boilerplate,
384 allocation_site,
385 alloc_site_mode,
386 FAST_ELEMENTS));
387 if_fixed_cow.Else();
388 IfBuilder if_fixed(this);
389 if_fixed.If<HCompareMap>(elements, factory->fixed_array_map());
390 if_fixed.Then();
391 Push(BuildCloneShallowArrayNonEmpty(boilerplate,
392 allocation_site,
393 alloc_site_mode,
394 FAST_ELEMENTS));
375 395
376 IfBuilder if_fixed_cow(this); 396 if_fixed.Else();
377 if_fixed_cow.If<HCompareMap>(elements, factory->fixed_cow_array_map()); 397 Push(BuildCloneShallowArrayNonEmpty(boilerplate,
378 if_fixed_cow.Then(); 398 allocation_site,
379 push_value = BuildCloneShallowArray(boilerplate, 399 alloc_site_mode,
380 allocation_site, 400 FAST_DOUBLE_ELEMENTS));
381 alloc_site_mode, 401 if_fixed.End();
382 FAST_ELEMENTS, 402 if_fixed_cow.End();
383 0/*copy-on-write*/); 403 zero_capacity.End();
384 environment()->Push(push_value);
385 if_fixed_cow.Else();
386
387 IfBuilder if_fixed(this);
388 if_fixed.If<HCompareMap>(elements, factory->fixed_array_map());
389 if_fixed.Then();
390 push_value = BuildCloneShallowArray(boilerplate,
391 allocation_site,
392 alloc_site_mode,
393 FAST_ELEMENTS,
394 length);
395 environment()->Push(push_value);
396 if_fixed.Else();
397 push_value = BuildCloneShallowArray(boilerplate,
398 allocation_site,
399 alloc_site_mode,
400 FAST_DOUBLE_ELEMENTS,
401 length);
402 environment()->Push(push_value);
403 } else {
404 ElementsKind elements_kind = casted_stub()->ComputeElementsKind();
405 push_value = BuildCloneShallowArray(boilerplate,
406 allocation_site,
407 alloc_site_mode,
408 elements_kind,
409 length);
410 environment()->Push(push_value);
411 }
412 404
413 checker.ElseDeopt("Uninitialized boilerplate literals"); 405 checker.ElseDeopt("Uninitialized boilerplate literals");
414 checker.End(); 406 checker.End();
415 407
416 return environment()->Pop(); 408 return environment()->Pop();
417 } 409 }
418 410
419 411
420 Handle<Code> FastCloneShallowArrayStub::GenerateCode() { 412 Handle<Code> FastCloneShallowArrayStub::GenerateCode() {
421 return DoGenerateCode(this); 413 return DoGenerateCode(this);
(...skipping 1005 matching lines...) Expand 10 before | Expand all | Expand 10 after
1427 return BuildRegExpConstructResult(length, index, input); 1419 return BuildRegExpConstructResult(length, index, input);
1428 } 1420 }
1429 1421
1430 1422
1431 Handle<Code> RegExpConstructResultStub::GenerateCode() { 1423 Handle<Code> RegExpConstructResultStub::GenerateCode() {
1432 return DoGenerateCode(this); 1424 return DoGenerateCode(this);
1433 } 1425 }
1434 1426
1435 1427
1436 } } // namespace v8::internal 1428 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/code-stubs.cc ('k') | src/hydrogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698