| OLD | NEW |
| 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/js-builtin-reducer.h" | 5 #include "src/compiler/js-builtin-reducer.h" |
| 6 | 6 |
| 7 #include "src/compilation-dependencies.h" | 7 #include "src/compilation-dependencies.h" |
| 8 #include "src/compiler/access-builder.h" | 8 #include "src/compiler/access-builder.h" |
| 9 #include "src/compiler/js-graph.h" | 9 #include "src/compiler/js-graph.h" |
| 10 #include "src/compiler/node-matchers.h" | 10 #include "src/compiler/node-matchers.h" |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 if (HasInstanceTypeWitness(receiver, effect, JS_DATE_TYPE)) { | 377 if (HasInstanceTypeWitness(receiver, effect, JS_DATE_TYPE)) { |
| 378 Node* value = effect = graph()->NewNode( | 378 Node* value = effect = graph()->NewNode( |
| 379 simplified()->LoadField(AccessBuilder::ForJSDateValue()), receiver, | 379 simplified()->LoadField(AccessBuilder::ForJSDateValue()), receiver, |
| 380 effect, control); | 380 effect, control); |
| 381 ReplaceWithValue(node, value, effect, control); | 381 ReplaceWithValue(node, value, effect, control); |
| 382 return Replace(value); | 382 return Replace(value); |
| 383 } | 383 } |
| 384 return NoChange(); | 384 return NoChange(); |
| 385 } | 385 } |
| 386 | 386 |
| 387 // ES6 section 19.2.3.6 Function.prototype [ @@hasInstance ] ( V ) |
| 388 Reduction JSBuiltinReducer::ReduceFunctionHasInstance(Node* node) { |
| 389 Node* receiver = NodeProperties::GetValueInput(node, 1); |
| 390 Node* object = (node->op()->ValueInputCount() >= 3) |
| 391 ? NodeProperties::GetValueInput(node, 2) |
| 392 : jsgraph()->UndefinedConstant(); |
| 393 Node* context = NodeProperties::GetContextInput(node); |
| 394 Node* frame_state = NodeProperties::GetFrameStateInput(node); |
| 395 Node* effect = NodeProperties::GetEffectInput(node); |
| 396 Node* control = NodeProperties::GetControlInput(node); |
| 397 |
| 398 // TODO(turbofan): If JSOrdinaryToInstance raises an exception, the |
| 399 // stack trace doesn't contain the @@hasInstance call; we have the |
| 400 // corresponding bug in the baseline case. Some massaging of the frame |
| 401 // state would be necessary here. |
| 402 |
| 403 // Morph this {node} into a JSOrdinaryHasInstance node. |
| 404 node->ReplaceInput(0, receiver); |
| 405 node->ReplaceInput(1, object); |
| 406 node->ReplaceInput(2, context); |
| 407 node->ReplaceInput(3, frame_state); |
| 408 node->ReplaceInput(4, effect); |
| 409 node->ReplaceInput(5, control); |
| 410 node->TrimInputCount(6); |
| 411 NodeProperties::ChangeOp(node, javascript()->OrdinaryHasInstance()); |
| 412 return Changed(node); |
| 413 } |
| 414 |
| 387 // ES6 section 18.2.2 isFinite ( number ) | 415 // ES6 section 18.2.2 isFinite ( number ) |
| 388 Reduction JSBuiltinReducer::ReduceGlobalIsFinite(Node* node) { | 416 Reduction JSBuiltinReducer::ReduceGlobalIsFinite(Node* node) { |
| 389 JSCallReduction r(node); | 417 JSCallReduction r(node); |
| 390 if (r.InputsMatchOne(Type::PlainPrimitive())) { | 418 if (r.InputsMatchOne(Type::PlainPrimitive())) { |
| 391 // isFinite(a:plain-primitive) -> NumberEqual(a', a') | 419 // isFinite(a:plain-primitive) -> NumberEqual(a', a') |
| 392 // where a' = NumberSubtract(ToNumber(a), ToNumber(a)) | 420 // where a' = NumberSubtract(ToNumber(a), ToNumber(a)) |
| 393 Node* input = ToNumber(r.GetJSCallInput(0)); | 421 Node* input = ToNumber(r.GetJSCallInput(0)); |
| 394 Node* diff = graph()->NewNode(simplified()->NumberSubtract(), input, input); | 422 Node* diff = graph()->NewNode(simplified()->NumberSubtract(), input, input); |
| 395 Node* value = graph()->NewNode(simplified()->NumberEqual(), diff, diff); | 423 Node* value = graph()->NewNode(simplified()->NumberEqual(), diff, diff); |
| 396 return Replace(value); | 424 return Replace(value); |
| (...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1205 | 1233 |
| 1206 // Dispatch according to the BuiltinFunctionId if present. | 1234 // Dispatch according to the BuiltinFunctionId if present. |
| 1207 if (!r.HasBuiltinFunctionId()) return NoChange(); | 1235 if (!r.HasBuiltinFunctionId()) return NoChange(); |
| 1208 switch (r.GetBuiltinFunctionId()) { | 1236 switch (r.GetBuiltinFunctionId()) { |
| 1209 case kArrayPop: | 1237 case kArrayPop: |
| 1210 return ReduceArrayPop(node); | 1238 return ReduceArrayPop(node); |
| 1211 case kArrayPush: | 1239 case kArrayPush: |
| 1212 return ReduceArrayPush(node); | 1240 return ReduceArrayPush(node); |
| 1213 case kDateGetTime: | 1241 case kDateGetTime: |
| 1214 return ReduceDateGetTime(node); | 1242 return ReduceDateGetTime(node); |
| 1243 case kFunctionHasInstance: |
| 1244 return ReduceFunctionHasInstance(node); |
| 1245 break; |
| 1215 case kGlobalIsFinite: | 1246 case kGlobalIsFinite: |
| 1216 reduction = ReduceGlobalIsFinite(node); | 1247 reduction = ReduceGlobalIsFinite(node); |
| 1217 break; | 1248 break; |
| 1218 case kGlobalIsNaN: | 1249 case kGlobalIsNaN: |
| 1219 reduction = ReduceGlobalIsNaN(node); | 1250 reduction = ReduceGlobalIsNaN(node); |
| 1220 break; | 1251 break; |
| 1221 case kMathAbs: | 1252 case kMathAbs: |
| 1222 reduction = ReduceMathAbs(node); | 1253 reduction = ReduceMathAbs(node); |
| 1223 break; | 1254 break; |
| 1224 case kMathAcos: | 1255 case kMathAcos: |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1400 return jsgraph()->simplified(); | 1431 return jsgraph()->simplified(); |
| 1401 } | 1432 } |
| 1402 | 1433 |
| 1403 JSOperatorBuilder* JSBuiltinReducer::javascript() const { | 1434 JSOperatorBuilder* JSBuiltinReducer::javascript() const { |
| 1404 return jsgraph()->javascript(); | 1435 return jsgraph()->javascript(); |
| 1405 } | 1436 } |
| 1406 | 1437 |
| 1407 } // namespace compiler | 1438 } // namespace compiler |
| 1408 } // namespace internal | 1439 } // namespace internal |
| 1409 } // namespace v8 | 1440 } // namespace v8 |
| OLD | NEW |