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

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: Fix integer overflow. 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
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
197 // Dispatch according to the BuiltinFunctionId if present. 222 // Dispatch according to the BuiltinFunctionId if present.
198 if (!r.HasBuiltinFunctionId()) return NoChange(); 223 if (!r.HasBuiltinFunctionId()) return NoChange();
199 switch (r.GetBuiltinFunctionId()) { 224 switch (r.GetBuiltinFunctionId()) {
200 case kMathAbs: 225 case kMathAbs:
201 return ReplaceWithPureReduction(node, ReduceMathAbs(node)); 226 return ReplaceWithPureReduction(node, ReduceMathAbs(node));
202 case kMathSqrt: 227 case kMathSqrt:
203 return ReplaceWithPureReduction(node, ReduceMathSqrt(node)); 228 return ReplaceWithPureReduction(node, ReduceMathSqrt(node));
204 case kMathMax: 229 case kMathMax:
205 return ReplaceWithPureReduction(node, ReduceMathMax(node)); 230 return ReplaceWithPureReduction(node, ReduceMathMax(node));
206 case kMathImul: 231 case kMathImul:
207 return ReplaceWithPureReduction(node, ReduceMathImul(node)); 232 return ReplaceWithPureReduction(node, ReduceMathImul(node));
208 case kMathFround: 233 case kMathFround:
209 return ReplaceWithPureReduction(node, ReduceMathFround(node)); 234 return ReplaceWithPureReduction(node, ReduceMathFround(node));
235 case kMathFloor:
236 return ReplaceWithPureReduction(node, ReduceMathFloor(node));
237 case kMathCeil:
238 return ReplaceWithPureReduction(node, ReduceMathCeil(node));
210 default: 239 default:
211 break; 240 break;
212 } 241 }
213 return NoChange(); 242 return NoChange();
214 } 243 }
215 244
216 } // namespace compiler 245 } // namespace compiler
217 } // namespace internal 246 } // namespace internal
218 } // namespace v8 247 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698