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

Side by Side Diff: src/compiler/typer.cc

Issue 953563002: Implement experimental exponentiation operator (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add more tests and fix some bugs Created 5 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
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/base/flags.h" 5 #include "src/base/flags.h"
6 #include "src/bootstrapper.h" 6 #include "src/bootstrapper.h"
7 #include "src/compiler/graph-reducer.h" 7 #include "src/compiler/graph-reducer.h"
8 #include "src/compiler/js-operator.h" 8 #include "src/compiler/js-operator.h"
9 #include "src/compiler/node.h" 9 #include "src/compiler/node.h"
10 #include "src/compiler/node-properties.h" 10 #include "src/compiler/node-properties.h"
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 static Type* ToNumber(Type*, Typer*); 343 static Type* ToNumber(Type*, Typer*);
344 static Type* ToString(Type*, Typer*); 344 static Type* ToString(Type*, Typer*);
345 static Type* NumberToInt32(Type*, Typer*); 345 static Type* NumberToInt32(Type*, Typer*);
346 static Type* NumberToUint32(Type*, Typer*); 346 static Type* NumberToUint32(Type*, Typer*);
347 347
348 static Type* JSAddRanger(Type::RangeType*, Type::RangeType*, Typer*); 348 static Type* JSAddRanger(Type::RangeType*, Type::RangeType*, Typer*);
349 static Type* JSSubtractRanger(Type::RangeType*, Type::RangeType*, Typer*); 349 static Type* JSSubtractRanger(Type::RangeType*, Type::RangeType*, Typer*);
350 static Type* JSMultiplyRanger(Type::RangeType*, Type::RangeType*, Typer*); 350 static Type* JSMultiplyRanger(Type::RangeType*, Type::RangeType*, Typer*);
351 static Type* JSDivideRanger(Type::RangeType*, Type::RangeType*, Typer*); 351 static Type* JSDivideRanger(Type::RangeType*, Type::RangeType*, Typer*);
352 static Type* JSModulusRanger(Type::RangeType*, Type::RangeType*, Typer*); 352 static Type* JSModulusRanger(Type::RangeType*, Type::RangeType*, Typer*);
353 static Type* JSExponentiateRanger(Type::RangeType*, Type::RangeType*, Typer*);
353 354
354 static ComparisonOutcome JSCompareTyper(Type*, Type*, Typer*); 355 static ComparisonOutcome JSCompareTyper(Type*, Type*, Typer*);
355 356
356 #define DECLARE_METHOD(x) static Type* x##Typer(Type*, Type*, Typer*); 357 #define DECLARE_METHOD(x) static Type* x##Typer(Type*, Type*, Typer*);
357 JS_SIMPLE_BINOP_LIST(DECLARE_METHOD) 358 JS_SIMPLE_BINOP_LIST(DECLARE_METHOD)
358 #undef DECLARE_METHOD 359 #undef DECLARE_METHOD
359 360
360 static Type* JSUnaryNotTyper(Type*, Typer*); 361 static Type* JSUnaryNotTyper(Type*, Typer*);
361 static Type* JSLoadPropertyTyper(Type*, Type*, Typer*); 362 static Type* JSLoadPropertyTyper(Type*, Type*, Typer*);
362 static Type* JSCallFunctionTyper(Type*, Typer*); 363 static Type* JSCallFunctionTyper(Type*, Typer*);
(...skipping 853 matching lines...) Expand 10 before | Expand all | Expand 10 after
1216 1217
1217 lhs = Rangify(lhs, t); 1218 lhs = Rangify(lhs, t);
1218 rhs = Rangify(rhs, t); 1219 rhs = Rangify(rhs, t);
1219 if (lhs->IsRange() && rhs->IsRange()) { 1220 if (lhs->IsRange() && rhs->IsRange()) {
1220 return JSModulusRanger(lhs->AsRange(), rhs->AsRange(), t); 1221 return JSModulusRanger(lhs->AsRange(), rhs->AsRange(), t);
1221 } 1222 }
1222 return Type::OrderedNumber(); 1223 return Type::OrderedNumber();
1223 } 1224 }
1224 1225
1225 1226
1227 Type* Typer::Visitor::JSExponentiateRanger(Type::RangeType* lhs,
1228 Type::RangeType* rhs, Typer* t) {
1229 return Type::Range(-V8_INFINITY, +V8_INFINITY, t->zone());
Michael Starzinger 2015/02/24 14:09:03 This is a pretty broad range. :)
caitp (gmail) 2015/02/24 14:56:12 I have some ideas for how to make it a bit more na
1230 }
1231
1232
1233 Type* Typer::Visitor::JSExponentiateTyper(Type* lhs, Type* rhs, Typer* t) {
1234 if (lhs->Is(Type::NaN()) || rhs->Is(Type::NaN())) return Type::NaN();
Michael Starzinger 2015/02/24 14:09:03 Isn't the exponentiation supposed to perform an im
caitp (gmail) 2015/02/24 14:56:12 I might be misunderstanding what the typer is doin
1235 return Type::Number();
1236 }
1237
1238
1226 // JS unary operators. 1239 // JS unary operators.
1227 1240
1228 1241
1229 Type* Typer::Visitor::JSUnaryNotTyper(Type* type, Typer* t) { 1242 Type* Typer::Visitor::JSUnaryNotTyper(Type* type, Typer* t) {
1230 return Invert(ToBoolean(type, t), t); 1243 return Invert(ToBoolean(type, t), t);
1231 } 1244 }
1232 1245
1233 1246
1234 Bounds Typer::Visitor::TypeJSUnaryNot(Node* node) { 1247 Bounds Typer::Visitor::TypeJSUnaryNot(Node* node) {
1235 return TypeUnaryOp(node, JSUnaryNotTyper); 1248 return TypeUnaryOp(node, JSUnaryNotTyper);
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
1569 Bounds Typer::Visitor::TypeNumberDivide(Node* node) { 1582 Bounds Typer::Visitor::TypeNumberDivide(Node* node) {
1570 return Bounds(Type::None(zone()), Type::Number(zone())); 1583 return Bounds(Type::None(zone()), Type::Number(zone()));
1571 } 1584 }
1572 1585
1573 1586
1574 Bounds Typer::Visitor::TypeNumberModulus(Node* node) { 1587 Bounds Typer::Visitor::TypeNumberModulus(Node* node) {
1575 return Bounds(Type::None(zone()), Type::Number(zone())); 1588 return Bounds(Type::None(zone()), Type::Number(zone()));
1576 } 1589 }
1577 1590
1578 1591
1592 Bounds Typer::Visitor::TypeNumberExponentiate(Node* node) {
1593 return Bounds(Type::None(zone()), Type::Number(zone()));
1594 }
1595
1596
1579 Bounds Typer::Visitor::TypeNumberToInt32(Node* node) { 1597 Bounds Typer::Visitor::TypeNumberToInt32(Node* node) {
1580 return TypeUnaryOp(node, NumberToInt32); 1598 return TypeUnaryOp(node, NumberToInt32);
1581 } 1599 }
1582 1600
1583 1601
1584 Bounds Typer::Visitor::TypeNumberToUint32(Node* node) { 1602 Bounds Typer::Visitor::TypeNumberToUint32(Node* node) {
1585 return TypeUnaryOp(node, NumberToUint32); 1603 return TypeUnaryOp(node, NumberToUint32);
1586 } 1604 }
1587 1605
1588 1606
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after
2184 TYPED_ARRAYS(TYPED_ARRAY_CASE) 2202 TYPED_ARRAYS(TYPED_ARRAY_CASE)
2185 #undef TYPED_ARRAY_CASE 2203 #undef TYPED_ARRAY_CASE
2186 } 2204 }
2187 } 2205 }
2188 return Type::Constant(value, zone()); 2206 return Type::Constant(value, zone());
2189 } 2207 }
2190 2208
2191 } // namespace compiler 2209 } // namespace compiler
2192 } // namespace internal 2210 } // namespace internal
2193 } // namespace v8 2211 } // namespace v8
OLDNEW
« src/compiler/opcodes.h ('K') | « src/compiler/opcodes.h ('k') | src/compiler/verifier.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698