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

Side by Side Diff: src/compiler/js-builtin-reducer.cc

Issue 677433002: Add floor, ceil, round (truncate) instructions for ia32, x64 (if SSE4.1) and (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address changes and fix compilation on mac. Created 6 years, 1 month 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/compiler/js-builtin-reducer.h ('k') | src/compiler/mips/instruction-selector-mips.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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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/graph-inl.h" 5 #include "src/compiler/graph-inl.h"
6 #include "src/compiler/js-builtin-reducer.h" 6 #include "src/compiler/js-builtin-reducer.h"
7 #include "src/compiler/node-matchers.h" 7 #include "src/compiler/node-matchers.h"
8 #include "src/compiler/node-properties-inl.h" 8 #include "src/compiler/node-properties-inl.h"
9 #include "src/types.h" 9 #include "src/types.h"
10 10
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 if (r.InputsMatchOne(Type::Number())) { 184 if (r.InputsMatchOne(Type::Number())) {
185 // Math.fround(a:number) -> TruncateFloat64ToFloat32(a) 185 // Math.fround(a:number) -> TruncateFloat64ToFloat32(a)
186 Node* value = 186 Node* value =
187 graph()->NewNode(machine()->TruncateFloat64ToFloat32(), r.left()); 187 graph()->NewNode(machine()->TruncateFloat64ToFloat32(), r.left());
188 return Replace(value); 188 return Replace(value);
189 } 189 }
190 return NoChange(); 190 return NoChange();
191 } 191 }
192 192
193 193
194 // ES6 draft 10-14-14, section 20.2.2.16.
195 Reduction JSBuiltinReducer::ReduceMathFloor(Node* node) {
196 if (!machine()->HasFloat64Floor()) return NoChange();
197 JSCallReduction r(node);
198 if (r.InputsMatchOne(Type::Number())) {
199 // Math.floor(a:number) -> Float64Floor(a)
200 Node* value = graph()->NewNode(machine()->Float64Floor(), r.left());
201 return Replace(value);
202 }
203 return NoChange();
204 }
205
206
207 // ES6 draft 10-14-14, section 20.2.2.10.
208 Reduction JSBuiltinReducer::ReduceMathCeil(Node* node) {
209 if (!machine()->HasFloat64Ceil()) return NoChange();
210 JSCallReduction r(node);
211 if (r.InputsMatchOne(Type::Number())) {
212 // Math.ceil(a:number) -> Float64Ceil(a)
213 Node* value = graph()->NewNode(machine()->Float64Ceil(), r.left());
214 return Replace(value);
215 }
216 return NoChange();
217 }
218
219
194 Reduction JSBuiltinReducer::Reduce(Node* node) { 220 Reduction JSBuiltinReducer::Reduce(Node* node) {
195 JSCallReduction r(node); 221 JSCallReduction r(node);
196 222
197 // Dispatch according to the BuiltinFunctionId if present. 223 // Dispatch according to the BuiltinFunctionId if present.
198 if (!r.HasBuiltinFunctionId()) return NoChange(); 224 if (!r.HasBuiltinFunctionId()) return NoChange();
199 switch (r.GetBuiltinFunctionId()) { 225 switch (r.GetBuiltinFunctionId()) {
200 case kMathAbs: 226 case kMathAbs:
201 return ReplaceWithPureReduction(node, ReduceMathAbs(node)); 227 return ReplaceWithPureReduction(node, ReduceMathAbs(node));
202 case kMathSqrt: 228 case kMathSqrt:
203 return ReplaceWithPureReduction(node, ReduceMathSqrt(node)); 229 return ReplaceWithPureReduction(node, ReduceMathSqrt(node));
204 case kMathMax: 230 case kMathMax:
205 return ReplaceWithPureReduction(node, ReduceMathMax(node)); 231 return ReplaceWithPureReduction(node, ReduceMathMax(node));
206 case kMathImul: 232 case kMathImul:
207 return ReplaceWithPureReduction(node, ReduceMathImul(node)); 233 return ReplaceWithPureReduction(node, ReduceMathImul(node));
208 case kMathFround: 234 case kMathFround:
209 return ReplaceWithPureReduction(node, ReduceMathFround(node)); 235 return ReplaceWithPureReduction(node, ReduceMathFround(node));
236 case kMathFloor:
237 return ReplaceWithPureReduction(node, ReduceMathFloor(node));
238 case kMathCeil:
239 return ReplaceWithPureReduction(node, ReduceMathCeil(node));
210 default: 240 default:
211 break; 241 break;
212 } 242 }
213 return NoChange(); 243 return NoChange();
214 } 244 }
215 245
216 } // namespace compiler 246 } // namespace compiler
217 } // namespace internal 247 } // namespace internal
218 } // namespace v8 248 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/js-builtin-reducer.h ('k') | src/compiler/mips/instruction-selector-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698