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

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

Issue 139973004: A64: Synchronize with r15814. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 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/codegen.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 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 ASSERT(descriptor->stack_parameter_count_ == NULL); 300 ASSERT(descriptor->stack_parameter_count_ == NULL);
301 return stub->GenerateLightweightMissCode(isolate); 301 return stub->GenerateLightweightMissCode(isolate);
302 } 302 }
303 CodeStubGraphBuilder<Stub> builder(stub); 303 CodeStubGraphBuilder<Stub> builder(stub);
304 LChunk* chunk = OptimizeGraph(builder.CreateGraph()); 304 LChunk* chunk = OptimizeGraph(builder.CreateGraph());
305 return chunk->Codegen(); 305 return chunk->Codegen();
306 } 306 }
307 307
308 308
309 template <> 309 template <>
310 HValue* CodeStubGraphBuilder<ToNumberStub>::BuildCodeStub() {
311 HValue* value = GetParameter(0);
312
313 // Check if the parameter is already a SMI or heap number.
314 IfBuilder if_number(this);
315 if_number.If<HIsSmiAndBranch>(value);
316 if_number.OrIf<HCompareMap>(value, isolate()->factory()->heap_number_map());
317 if_number.Then();
318
319 // Return the number.
320 Push(value);
321
322 if_number.Else();
323
324 // Convert the parameter to number using the builtin.
325 HValue* function = AddLoadJSBuiltin(Builtins::TO_NUMBER, context());
326 Add<HPushArgument>(value);
327 Push(Add<HInvokeFunction>(context(), function, 1));
328
329 if_number.End();
330
331 return Pop();
332 }
333
334
335 Handle<Code> ToNumberStub::GenerateCode() {
336 return DoGenerateCode(this);
337 }
338
339
340 template <>
310 HValue* CodeStubGraphBuilder<FastCloneShallowArrayStub>::BuildCodeStub() { 341 HValue* CodeStubGraphBuilder<FastCloneShallowArrayStub>::BuildCodeStub() {
311 Zone* zone = this->zone(); 342 Zone* zone = this->zone();
312 Factory* factory = isolate()->factory(); 343 Factory* factory = isolate()->factory();
313 HValue* undefined = graph()->GetConstantUndefined(); 344 HValue* undefined = graph()->GetConstantUndefined();
314 AllocationSiteMode alloc_site_mode = casted_stub()->allocation_site_mode(); 345 AllocationSiteMode alloc_site_mode = casted_stub()->allocation_site_mode();
315 FastCloneShallowArrayStub::Mode mode = casted_stub()->mode(); 346 FastCloneShallowArrayStub::Mode mode = casted_stub()->mode();
316 int length = casted_stub()->length(); 347 int length = casted_stub()->length();
317 348
318 HInstruction* allocation_site = 349 HInstruction* allocation_site =
319 AddInstruction(new(zone) HLoadKeyed(GetParameter(0), 350 AddInstruction(new(zone) HLoadKeyed(GetParameter(0),
320 GetParameter(1), 351 GetParameter(1),
321 NULL, 352 NULL,
322 FAST_ELEMENTS)); 353 FAST_ELEMENTS));
323 IfBuilder checker(this); 354 IfBuilder checker(this);
324 checker.IfNot<HCompareObjectEqAndBranch, HValue*>(allocation_site, undefined); 355 checker.IfNot<HCompareObjectEqAndBranch, HValue*>(allocation_site, undefined);
325 checker.Then(); 356 checker.Then();
326 357
327 HObjectAccess access = HObjectAccess::ForAllocationSiteInfoSite(); 358 HObjectAccess access = HObjectAccess::ForAllocationSiteTransitionInfo();
328 HInstruction* boilerplate = AddLoad(allocation_site, access); 359 HInstruction* boilerplate = AddLoad(allocation_site, access);
329 if (mode == FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS) { 360 if (mode == FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS) {
330 HValue* elements = AddLoadElements(boilerplate); 361 HValue* elements = AddLoadElements(boilerplate);
331 362
332 IfBuilder if_fixed_cow(this); 363 IfBuilder if_fixed_cow(this);
333 if_fixed_cow.If<HCompareMap>(elements, factory->fixed_cow_array_map()); 364 if_fixed_cow.If<HCompareMap>(elements, factory->fixed_cow_array_map());
334 if_fixed_cow.Then(); 365 if_fixed_cow.Then();
335 environment()->Push(BuildCloneShallowArray(context(), 366 environment()->Push(BuildCloneShallowArray(context(),
336 boilerplate, 367 boilerplate,
337 allocation_site, 368 allocation_site,
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 HAllocate(context(), size, HType::JSObject(), flags)); 469 HAllocate(context(), size, HType::JSObject(), flags));
439 470
440 // Store the map 471 // Store the map
441 Handle<Map> allocation_site_map(isolate()->heap()->allocation_site_map(), 472 Handle<Map> allocation_site_map(isolate()->heap()->allocation_site_map(),
442 isolate()); 473 isolate());
443 AddStoreMapConstant(object, allocation_site_map); 474 AddStoreMapConstant(object, allocation_site_map);
444 475
445 // Store the payload (smi elements kind) 476 // Store the payload (smi elements kind)
446 HValue* initial_elements_kind = AddInstruction(new(zone) HConstant( 477 HValue* initial_elements_kind = AddInstruction(new(zone) HConstant(
447 GetInitialFastElementsKind())); 478 GetInitialFastElementsKind()));
448 AddInstruction(new(zone) HStoreNamedField(object, 479 Add<HStoreNamedField>(object,
449 HObjectAccess::ForAllocationSiteTransitionInfo(), initial_elements_kind)); 480 HObjectAccess::ForAllocationSiteTransitionInfo(),
481 initial_elements_kind);
482
483 Add<HLinkObjectInList>(object, HObjectAccess::ForAllocationSiteWeakNext(),
484 HLinkObjectInList::ALLOCATION_SITE_LIST);
450 485
451 // We use a hammer (SkipWriteBarrier()) to indicate that we know the input 486 // We use a hammer (SkipWriteBarrier()) to indicate that we know the input
452 // cell is really a Cell, and so no write barrier is needed. 487 // cell is really a Cell, and so no write barrier is needed.
453 // TODO(mvstanton): Add a debug_code check to verify the input cell is really 488 // TODO(mvstanton): Add a debug_code check to verify the input cell is really
454 // a cell. (perhaps with a new instruction, HAssert). 489 // a cell. (perhaps with a new instruction, HAssert).
455 HInstruction* cell = GetParameter(0); 490 HInstruction* cell = GetParameter(0);
456 HObjectAccess access = HObjectAccess::ForCellValue(); 491 HObjectAccess access = HObjectAccess::ForCellValue();
457 HStoreNamedField* store = AddStore(cell, access, object); 492 HStoreNamedField* store = AddStore(cell, access, object);
458 store->SkipWriteBarrier(); 493 store->SkipWriteBarrier();
459 return cell; 494 return cell;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 } 556 }
522 557
523 558
524 Handle<Code> KeyedStoreFastElementStub::GenerateCode() { 559 Handle<Code> KeyedStoreFastElementStub::GenerateCode() {
525 return DoGenerateCode(this); 560 return DoGenerateCode(this);
526 } 561 }
527 562
528 563
529 template <> 564 template <>
530 HValue* CodeStubGraphBuilder<TransitionElementsKindStub>::BuildCodeStub() { 565 HValue* CodeStubGraphBuilder<TransitionElementsKindStub>::BuildCodeStub() {
531 TransitionElementsKindStub* stub = casted_stub();
532 ElementsKind from_kind = stub->from_kind();
533 ElementsKind to_kind = stub->to_kind();
534
535 HValue* js_array = GetParameter(0);
536 HValue* map = GetParameter(1);
537
538 info()->MarkAsSavesCallerDoubles(); 566 info()->MarkAsSavesCallerDoubles();
539 567
540 if (AllocationSite::GetMode(from_kind, to_kind) == TRACK_ALLOCATION_SITE) { 568 BuildTransitionElementsKind(GetParameter(0),
541 Add<HTrapAllocationMemento>(js_array); 569 GetParameter(1),
542 } 570 casted_stub()->from_kind(),
571 casted_stub()->to_kind(),
572 true);
543 573
544 HInstruction* elements = AddLoadElements(js_array); 574 return GetParameter(0);
545
546 HInstruction* empty_fixed_array = Add<HConstant>(
547 isolate()->factory()->empty_fixed_array(), Representation::Tagged());
548
549 IfBuilder if_builder(this);
550
551 if_builder.IfNot<HCompareObjectEqAndBranch>(elements, empty_fixed_array);
552
553 if_builder.Then();
554
555 HInstruction* elements_length = AddLoadFixedArrayLength(elements);
556
557 HInstruction* array_length = AddLoad(
558 js_array, HObjectAccess::ForArrayLength(), NULL, Representation::Smi());
559 array_length->set_type(HType::Smi());
560
561 BuildGrowElementsCapacity(js_array, elements, from_kind, to_kind,
562 array_length, elements_length);
563
564 if_builder.End();
565
566 AddStore(js_array, HObjectAccess::ForMap(), map);
567
568 return js_array;
569 } 575 }
570 576
571 577
572 Handle<Code> TransitionElementsKindStub::GenerateCode() { 578 Handle<Code> TransitionElementsKindStub::GenerateCode() {
573 return DoGenerateCode(this); 579 return DoGenerateCode(this);
574 } 580 }
575 581
576 HValue* CodeStubGraphBuilderBase::BuildArrayConstructor( 582 HValue* CodeStubGraphBuilderBase::BuildArrayConstructor(
577 ElementsKind kind, 583 ElementsKind kind,
578 ContextCheckMode context_mode, 584 ContextCheckMode context_mode,
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
868 HValue* CodeStubGraphBuilder<StoreGlobalStub>::BuildCodeInitializedStub() { 874 HValue* CodeStubGraphBuilder<StoreGlobalStub>::BuildCodeInitializedStub() {
869 StoreGlobalStub* stub = casted_stub(); 875 StoreGlobalStub* stub = casted_stub();
870 Handle<Object> hole(isolate()->heap()->the_hole_value(), isolate()); 876 Handle<Object> hole(isolate()->heap()->the_hole_value(), isolate());
871 Handle<Object> placeholer_value(Smi::FromInt(0), isolate()); 877 Handle<Object> placeholer_value(Smi::FromInt(0), isolate());
872 Handle<PropertyCell> placeholder_cell = 878 Handle<PropertyCell> placeholder_cell =
873 isolate()->factory()->NewPropertyCell(placeholer_value); 879 isolate()->factory()->NewPropertyCell(placeholer_value);
874 880
875 HParameter* receiver = GetParameter(0); 881 HParameter* receiver = GetParameter(0);
876 HParameter* value = GetParameter(2); 882 HParameter* value = GetParameter(2);
877 883
884 // Check that the map of the global has not changed: use a placeholder map
885 // that will be replaced later with the global object's map.
886 Handle<Map> placeholder_map = isolate()->factory()->meta_map();
887 AddInstruction(HCheckMaps::New(receiver, placeholder_map, zone()));
888
889 HValue* cell = Add<HConstant>(placeholder_cell, Representation::Tagged());
890 HObjectAccess access(HObjectAccess::ForCellPayload(isolate()));
891 HValue* cell_contents = Add<HLoadNamedField>(cell, access);
892
878 if (stub->is_constant()) { 893 if (stub->is_constant()) {
879 // Assume every store to a constant value changes it. 894 IfBuilder builder(this);
880 current_block()->FinishExitWithDeoptimization(HDeoptimize::kUseAll); 895 builder.If<HCompareObjectEqAndBranch>(cell_contents, value);
881 set_current_block(NULL); 896 builder.Then();
897 builder.ElseDeopt();
898 builder.End();
882 } else { 899 } else {
883 HValue* cell = Add<HConstant>(placeholder_cell, Representation::Tagged());
884
885 // Check that the map of the global has not changed: use a placeholder map
886 // that will be replaced later with the global object's map.
887 Handle<Map> placeholder_map = isolate()->factory()->meta_map();
888 AddInstruction(HCheckMaps::New(receiver, placeholder_map, zone()));
889
890 // Load the payload of the global parameter cell. A hole indicates that the 900 // Load the payload of the global parameter cell. A hole indicates that the
891 // property has been deleted and that the store must be handled by the 901 // property has been deleted and that the store must be handled by the
892 // runtime. 902 // runtime.
893 HObjectAccess access(HObjectAccess::ForCellPayload(isolate()));
894 HValue* cell_contents = Add<HLoadNamedField>(cell, access);
895 IfBuilder builder(this); 903 IfBuilder builder(this);
896 HValue* hole_value = Add<HConstant>(hole, Representation::Tagged()); 904 HValue* hole_value = Add<HConstant>(hole, Representation::Tagged());
897 builder.If<HCompareObjectEqAndBranch>(cell_contents, hole_value); 905 builder.If<HCompareObjectEqAndBranch>(cell_contents, hole_value);
898 builder.Then(); 906 builder.Then();
899 builder.Deopt(); 907 builder.Deopt();
900 builder.Else(); 908 builder.Else();
901 Add<HStoreNamedField>(cell, access, value); 909 Add<HStoreNamedField>(cell, access, value);
902 builder.End(); 910 builder.End();
903 } 911 }
912
904 return value; 913 return value;
905 } 914 }
906 915
907 916
908 Handle<Code> StoreGlobalStub::GenerateCode() { 917 Handle<Code> StoreGlobalStub::GenerateCode() {
909 return DoGenerateCode(this); 918 return DoGenerateCode(this);
910 } 919 }
911 920
912 921
922 template<>
923 HValue* CodeStubGraphBuilder<ElementsTransitionAndStoreStub>::BuildCodeStub() {
924 HValue* value = GetParameter(0);
925 HValue* map = GetParameter(1);
926 HValue* key = GetParameter(2);
927 HValue* object = GetParameter(3);
928
929 if (FLAG_trace_elements_transitions) {
930 // Tracing elements transitions is the job of the runtime.
931 current_block()->FinishExitWithDeoptimization(HDeoptimize::kUseAll);
932 set_current_block(NULL);
933 } else {
934 info()->MarkAsSavesCallerDoubles();
935
936 BuildTransitionElementsKind(object, map,
937 casted_stub()->from_kind(),
938 casted_stub()->to_kind(),
939 casted_stub()->is_jsarray());
940
941 BuildUncheckedMonomorphicElementAccess(object, key, value, NULL,
942 casted_stub()->is_jsarray(),
943 casted_stub()->to_kind(),
944 true, ALLOW_RETURN_HOLE,
945 casted_stub()->store_mode());
946 }
947
948 return value;
949 }
950
951
952 Handle<Code> ElementsTransitionAndStoreStub::GenerateCode() {
953 return DoGenerateCode(this);
954 }
955
956
913 } } // namespace v8::internal 957 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/code-stubs.cc ('k') | src/codegen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698