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

Side by Side Diff: src/compiler/js-intrinsic-lowering.cc

Issue 1579613002: [builtins] Refactor the remaining Date builtins. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: As per offline discussion, remove the weird test, which does not add a lot of value. Created 4 years, 11 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/compiler/js-intrinsic-lowering.h ('k') | src/compiler/linkage.cc » ('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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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/compiler/js-intrinsic-lowering.h" 5 #include "src/compiler/js-intrinsic-lowering.h"
6 6
7 #include <stack> 7 #include <stack>
8 8
9 #include "src/code-factory.h" 9 #include "src/code-factory.h"
10 #include "src/compiler/access-builder.h" 10 #include "src/compiler/access-builder.h"
(...skipping 21 matching lines...) Expand all
32 Reduction JSIntrinsicLowering::Reduce(Node* node) { 32 Reduction JSIntrinsicLowering::Reduce(Node* node) {
33 if (node->opcode() != IrOpcode::kJSCallRuntime) return NoChange(); 33 if (node->opcode() != IrOpcode::kJSCallRuntime) return NoChange();
34 const Runtime::Function* const f = 34 const Runtime::Function* const f =
35 Runtime::FunctionForId(CallRuntimeParametersOf(node->op()).id()); 35 Runtime::FunctionForId(CallRuntimeParametersOf(node->op()).id());
36 if (f->intrinsic_type != Runtime::IntrinsicType::INLINE) return NoChange(); 36 if (f->intrinsic_type != Runtime::IntrinsicType::INLINE) return NoChange();
37 switch (f->function_id) { 37 switch (f->function_id) {
38 case Runtime::kInlineConstructDouble: 38 case Runtime::kInlineConstructDouble:
39 return ReduceConstructDouble(node); 39 return ReduceConstructDouble(node);
40 case Runtime::kInlineCreateIterResultObject: 40 case Runtime::kInlineCreateIterResultObject:
41 return ReduceCreateIterResultObject(node); 41 return ReduceCreateIterResultObject(node);
42 case Runtime::kInlineDateField:
43 return ReduceDateField(node);
44 case Runtime::kInlineDeoptimizeNow: 42 case Runtime::kInlineDeoptimizeNow:
45 return ReduceDeoptimizeNow(node); 43 return ReduceDeoptimizeNow(node);
46 case Runtime::kInlineDoubleHi: 44 case Runtime::kInlineDoubleHi:
47 return ReduceDoubleHi(node); 45 return ReduceDoubleHi(node);
48 case Runtime::kInlineDoubleLo: 46 case Runtime::kInlineDoubleLo:
49 return ReduceDoubleLo(node); 47 return ReduceDoubleLo(node);
50 case Runtime::kInlineIncrementStatsCounter: 48 case Runtime::kInlineIncrementStatsCounter:
51 return ReduceIncrementStatsCounter(node); 49 return ReduceIncrementStatsCounter(node);
52 case Runtime::kInlineIsArray: 50 case Runtime::kInlineIsArray:
53 return ReduceIsInstanceType(node, JS_ARRAY_TYPE); 51 return ReduceIsInstanceType(node, JS_ARRAY_TYPE);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 case Runtime::kInlineToName: 94 case Runtime::kInlineToName:
97 return ReduceToName(node); 95 return ReduceToName(node);
98 case Runtime::kInlineToNumber: 96 case Runtime::kInlineToNumber:
99 return ReduceToNumber(node); 97 return ReduceToNumber(node);
100 case Runtime::kInlineToObject: 98 case Runtime::kInlineToObject:
101 return ReduceToObject(node); 99 return ReduceToObject(node);
102 case Runtime::kInlineToPrimitive: 100 case Runtime::kInlineToPrimitive:
103 return ReduceToPrimitive(node); 101 return ReduceToPrimitive(node);
104 case Runtime::kInlineToString: 102 case Runtime::kInlineToString:
105 return ReduceToString(node); 103 return ReduceToString(node);
106 case Runtime::kInlineThrowNotDateError:
107 return ReduceThrowNotDateError(node);
108 case Runtime::kInlineCall: 104 case Runtime::kInlineCall:
109 return ReduceCall(node); 105 return ReduceCall(node);
110 case Runtime::kInlineTailCall: 106 case Runtime::kInlineTailCall:
111 return ReduceTailCall(node); 107 return ReduceTailCall(node);
112 case Runtime::kInlineGetSuperConstructor: 108 case Runtime::kInlineGetSuperConstructor:
113 return ReduceGetSuperConstructor(node); 109 return ReduceGetSuperConstructor(node);
114 default: 110 default:
115 break; 111 break;
116 } 112 }
117 return NoChange(); 113 return NoChange();
(...skipping 16 matching lines...) Expand all
134 Node* value = 130 Node* value =
135 graph()->NewNode(machine()->Float64InsertHighWord32(), 131 graph()->NewNode(machine()->Float64InsertHighWord32(),
136 graph()->NewNode(machine()->Float64InsertLowWord32(), 132 graph()->NewNode(machine()->Float64InsertLowWord32(),
137 jsgraph()->Constant(0), low), 133 jsgraph()->Constant(0), low),
138 high); 134 high);
139 ReplaceWithValue(node, value); 135 ReplaceWithValue(node, value);
140 return Replace(value); 136 return Replace(value);
141 } 137 }
142 138
143 139
144 Reduction JSIntrinsicLowering::ReduceDateField(Node* node) {
145 Node* const value = NodeProperties::GetValueInput(node, 0);
146 Node* const index = NodeProperties::GetValueInput(node, 1);
147 Node* const effect = NodeProperties::GetEffectInput(node);
148 Node* const control = NodeProperties::GetControlInput(node);
149 NumberMatcher mindex(index);
150 if (mindex.Is(JSDate::kDateValue)) {
151 return Change(
152 node,
153 simplified()->LoadField(AccessBuilder::ForJSDateField(
154 static_cast<JSDate::FieldIndex>(static_cast<int>(mindex.Value())))),
155 value, effect, control);
156 }
157 // TODO(turbofan): Optimize more patterns.
158 return NoChange();
159 }
160
161
162 Reduction JSIntrinsicLowering::ReduceDeoptimizeNow(Node* node) { 140 Reduction JSIntrinsicLowering::ReduceDeoptimizeNow(Node* node) {
163 if (mode() != kDeoptimizationEnabled) return NoChange(); 141 if (mode() != kDeoptimizationEnabled) return NoChange();
164 Node* const frame_state = NodeProperties::GetFrameStateInput(node, 0); 142 Node* const frame_state = NodeProperties::GetFrameStateInput(node, 0);
165 Node* const effect = NodeProperties::GetEffectInput(node); 143 Node* const effect = NodeProperties::GetEffectInput(node);
166 Node* const control = NodeProperties::GetControlInput(node); 144 Node* const control = NodeProperties::GetControlInput(node);
167 145
168 // TODO(bmeurer): Move MergeControlToEnd() to the AdvancedReducer. 146 // TODO(bmeurer): Move MergeControlToEnd() to the AdvancedReducer.
169 Node* deoptimize = 147 Node* deoptimize =
170 graph()->NewNode(common()->Deoptimize(DeoptimizeKind::kEager), 148 graph()->NewNode(common()->Deoptimize(DeoptimizeKind::kEager),
171 frame_state, effect, control); 149 frame_state, effect, control);
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 simplified()->LoadField(AccessBuilder::ForJSRegExpSource()); 498 simplified()->LoadField(AccessBuilder::ForJSRegExpSource());
521 return Change(node, op, receiver, effect, control); 499 return Change(node, op, receiver, effect, control);
522 } 500 }
523 501
524 502
525 Reduction JSIntrinsicLowering::ReduceSubString(Node* node) { 503 Reduction JSIntrinsicLowering::ReduceSubString(Node* node) {
526 return Change(node, CodeFactory::SubString(isolate()), 3); 504 return Change(node, CodeFactory::SubString(isolate()), 3);
527 } 505 }
528 506
529 507
530 Reduction JSIntrinsicLowering::ReduceThrowNotDateError(Node* node) {
531 if (mode() != kDeoptimizationEnabled) return NoChange();
532 Node* const frame_state = NodeProperties::GetFrameStateInput(node, 1);
533 Node* const effect = NodeProperties::GetEffectInput(node);
534 Node* const control = NodeProperties::GetControlInput(node);
535
536 // TODO(bmeurer): Move MergeControlToEnd() to the AdvancedReducer.
537 Node* deoptimize =
538 graph()->NewNode(common()->Deoptimize(DeoptimizeKind::kEager),
539 frame_state, effect, control);
540 NodeProperties::MergeControlToEnd(graph(), common(), deoptimize);
541
542 node->TrimInputCount(0);
543 NodeProperties::ChangeOp(node, common()->Dead());
544 return Changed(node);
545 }
546
547
548 Reduction JSIntrinsicLowering::ReduceToInteger(Node* node) { 508 Reduction JSIntrinsicLowering::ReduceToInteger(Node* node) {
549 Node* value = NodeProperties::GetValueInput(node, 0); 509 Node* value = NodeProperties::GetValueInput(node, 0);
550 Type* value_type = NodeProperties::GetType(value); 510 Type* value_type = NodeProperties::GetType(value);
551 if (value_type->Is(type_cache().kIntegerOrMinusZero)) { 511 if (value_type->Is(type_cache().kIntegerOrMinusZero)) {
552 ReplaceWithValue(node, value); 512 ReplaceWithValue(node, value);
553 return Replace(value); 513 return Replace(value);
554 } 514 }
555 return NoChange(); 515 return NoChange();
556 } 516 }
557 517
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 } 693 }
734 694
735 695
736 SimplifiedOperatorBuilder* JSIntrinsicLowering::simplified() const { 696 SimplifiedOperatorBuilder* JSIntrinsicLowering::simplified() const {
737 return jsgraph()->simplified(); 697 return jsgraph()->simplified();
738 } 698 }
739 699
740 } // namespace compiler 700 } // namespace compiler
741 } // namespace internal 701 } // namespace internal
742 } // namespace v8 702 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/js-intrinsic-lowering.h ('k') | src/compiler/linkage.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698