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

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

Issue 1827523005: [turbofan] Reduce boilerplate around HeapNumber allocation in stubs. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 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
« no previous file with comments | « src/builtins.cc ('k') | src/compiler/code-stub-assembler.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 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/code-stubs.h" 5 #include "src/code-stubs.h"
6 6
7 #include <sstream> 7 #include <sstream>
8 8
9 #include "src/bootstrapper.h" 9 #include "src/bootstrapper.h"
10 #include "src/code-factory.h" 10 #include "src/code-factory.h"
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 Zone zone; 458 Zone zone;
459 CallInterfaceDescriptor descriptor(GetCallInterfaceDescriptor()); 459 CallInterfaceDescriptor descriptor(GetCallInterfaceDescriptor());
460 compiler::CodeStubAssembler assembler(isolate(), &zone, descriptor, 460 compiler::CodeStubAssembler assembler(isolate(), &zone, descriptor,
461 GetCodeFlags(), name); 461 GetCodeFlags(), name);
462 GenerateAssembly(&assembler); 462 GenerateAssembly(&assembler);
463 return assembler.GenerateCode(); 463 return assembler.GenerateCode();
464 } 464 }
465 465
466 void AllocateHeapNumberStub::GenerateAssembly( 466 void AllocateHeapNumberStub::GenerateAssembly(
467 compiler::CodeStubAssembler* assembler) const { 467 compiler::CodeStubAssembler* assembler) const {
468 compiler::Node* result = assembler->Allocate( 468 typedef compiler::Node Node;
469 HeapNumber::kSize, compiler::CodeStubAssembler::kNone); 469
470 compiler::Node* map_offset = 470 Node* result = assembler->AllocateHeapNumber();
471 assembler->IntPtrConstant(HeapObject::kMapOffset - kHeapObjectTag);
472 compiler::Node* map = assembler->IntPtrAdd(result, map_offset);
473 assembler->StoreNoWriteBarrier(
474 MachineRepresentation::kTagged, map,
475 assembler->HeapConstant(isolate()->factory()->heap_number_map()));
476 assembler->Return(result); 471 assembler->Return(result);
477 } 472 }
478 473
479 void AllocateMutableHeapNumberStub::GenerateAssembly( 474 void AllocateMutableHeapNumberStub::GenerateAssembly(
480 compiler::CodeStubAssembler* assembler) const { 475 compiler::CodeStubAssembler* assembler) const {
481 compiler::Node* result = assembler->Allocate( 476 typedef compiler::Node Node;
482 HeapNumber::kSize, compiler::CodeStubAssembler::kNone); 477
483 compiler::Node* map_offset = 478 Node* result = assembler->Allocate(HeapNumber::kSize);
484 assembler->IntPtrConstant(HeapObject::kMapOffset - kHeapObjectTag); 479 assembler->StoreMapNoWriteBarrier(
485 compiler::Node* map = assembler->IntPtrAdd(result, map_offset); 480 result,
486 assembler->StoreNoWriteBarrier(
487 MachineRepresentation::kTagged, map,
488 assembler->HeapConstant(isolate()->factory()->mutable_heap_number_map())); 481 assembler->HeapConstant(isolate()->factory()->mutable_heap_number_map()));
489 assembler->Return(result); 482 assembler->Return(result);
490 } 483 }
491 484
492 #define SIMD128_GEN_ASM(TYPE, Type, type, lane_count, lane_type) \ 485 #define SIMD128_GEN_ASM(TYPE, Type, type, lane_count, lane_type) \
493 void Allocate##Type##Stub::GenerateAssembly( \ 486 void Allocate##Type##Stub::GenerateAssembly( \
494 compiler::CodeStubAssembler* assembler) const { \ 487 compiler::CodeStubAssembler* assembler) const { \
495 compiler::Node* result = assembler->Allocate( \ 488 compiler::Node* result = assembler->Allocate( \
496 Simd128Value::kSize, compiler::CodeStubAssembler::kNone); \ 489 Simd128Value::kSize, compiler::CodeStubAssembler::kNone); \
497 compiler::Node* map_offset = \ 490 compiler::Node* map_offset = \
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
860 } 853 }
861 } 854 }
862 } 855 }
863 856
864 assembler->Bind(&do_fadd); 857 assembler->Bind(&do_fadd);
865 { 858 {
866 Node* lhs_value = var_fadd_lhs.value(); 859 Node* lhs_value = var_fadd_lhs.value();
867 Node* rhs_value = var_fadd_rhs.value(); 860 Node* rhs_value = var_fadd_rhs.value();
868 Node* value = assembler->Float64Add(lhs_value, rhs_value); 861 Node* value = assembler->Float64Add(lhs_value, rhs_value);
869 // TODO(bmeurer): Introduce a ChangeFloat64ToTagged. 862 // TODO(bmeurer): Introduce a ChangeFloat64ToTagged.
870 Node* result = assembler->Allocate(HeapNumber::kSize, 863 Node* result = assembler->AllocateHeapNumberWithValue(value);
871 compiler::CodeStubAssembler::kNone);
872 assembler->StoreMapNoWriteBarrier(result,
873 assembler->HeapNumberMapConstant());
874 assembler->StoreHeapNumberValue(result, value);
875 assembler->Return(result); 864 assembler->Return(result);
876 } 865 }
877 } 866 }
878 867
879 void SubtractStub::GenerateAssembly( 868 void SubtractStub::GenerateAssembly(
880 compiler::CodeStubAssembler* assembler) const { 869 compiler::CodeStubAssembler* assembler) const {
881 typedef compiler::CodeStubAssembler::Label Label; 870 typedef compiler::CodeStubAssembler::Label Label;
882 typedef compiler::Node Node; 871 typedef compiler::Node Node;
883 typedef compiler::CodeStubAssembler::Variable Variable; 872 typedef compiler::CodeStubAssembler::Variable Variable;
884 873
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
1033 } 1022 }
1034 } 1023 }
1035 } 1024 }
1036 1025
1037 assembler->Bind(&do_fsub); 1026 assembler->Bind(&do_fsub);
1038 { 1027 {
1039 Node* lhs_value = var_fsub_lhs.value(); 1028 Node* lhs_value = var_fsub_lhs.value();
1040 Node* rhs_value = var_fsub_rhs.value(); 1029 Node* rhs_value = var_fsub_rhs.value();
1041 Node* value = assembler->Float64Sub(lhs_value, rhs_value); 1030 Node* value = assembler->Float64Sub(lhs_value, rhs_value);
1042 // TODO(bmeurer): Introduce a ChangeFloat64ToTagged. 1031 // TODO(bmeurer): Introduce a ChangeFloat64ToTagged.
1043 Node* result = assembler->Allocate(HeapNumber::kSize, 1032 Node* result = assembler->AllocateHeapNumberWithValue(value);
1044 compiler::CodeStubAssembler::kNone);
1045 assembler->StoreMapNoWriteBarrier(result,
1046 assembler->HeapNumberMapConstant());
1047 assembler->StoreHeapNumberValue(result, value);
1048 assembler->Return(result); 1033 assembler->Return(result);
1049 } 1034 }
1050 } 1035 }
1051 1036
1052 namespace { 1037 namespace {
1053 1038
1054 enum RelationalComparisonMode { 1039 enum RelationalComparisonMode {
1055 kLessThan, 1040 kLessThan,
1056 kLessThanOrEqual, 1041 kLessThanOrEqual,
1057 kGreaterThan, 1042 kGreaterThan,
(...skipping 2293 matching lines...) Expand 10 before | Expand all | Expand 10 after
3351 if (type->Is(Type::UntaggedPointer())) { 3336 if (type->Is(Type::UntaggedPointer())) {
3352 return Representation::External(); 3337 return Representation::External();
3353 } 3338 }
3354 3339
3355 DCHECK(!type->Is(Type::Untagged())); 3340 DCHECK(!type->Is(Type::Untagged()));
3356 return Representation::Tagged(); 3341 return Representation::Tagged();
3357 } 3342 }
3358 3343
3359 } // namespace internal 3344 } // namespace internal
3360 } // namespace v8 3345 } // namespace v8
OLDNEW
« no previous file with comments | « src/builtins.cc ('k') | src/compiler/code-stub-assembler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698