Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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 <limits> | |
| 6 | |
| 5 #include "src/builtins/builtins-utils.h" | 7 #include "src/builtins/builtins-utils.h" |
| 6 #include "src/builtins/builtins.h" | 8 #include "src/builtins/builtins.h" |
| 7 #include "src/code-factory.h" | 9 #include "src/code-factory.h" |
| 8 #include "src/code-stub-assembler.h" | 10 #include "src/code-stub-assembler.h" |
| 9 #include "src/counters.h" | 11 #include "src/counters.h" |
| 10 #include "src/objects-inl.h" | 12 #include "src/objects-inl.h" |
| 11 | 13 |
| 12 namespace v8 { | 14 namespace v8 { |
| 13 namespace internal { | 15 namespace internal { |
| 14 | 16 |
| (...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 487 // ES6 section 20.2.2.34 Math.tanh ( x ) | 489 // ES6 section 20.2.2.34 Math.tanh ( x ) |
| 488 TF_BUILTIN(MathTanh, MathBuiltinsAssembler) { | 490 TF_BUILTIN(MathTanh, MathBuiltinsAssembler) { |
| 489 MathUnaryOperation(&CodeStubAssembler::Float64Tanh); | 491 MathUnaryOperation(&CodeStubAssembler::Float64Tanh); |
| 490 } | 492 } |
| 491 | 493 |
| 492 // ES6 section 20.2.2.35 Math.trunc ( x ) | 494 // ES6 section 20.2.2.35 Math.trunc ( x ) |
| 493 TF_BUILTIN(MathTrunc, MathBuiltinsAssembler) { | 495 TF_BUILTIN(MathTrunc, MathBuiltinsAssembler) { |
| 494 MathRoundingOperation(&CodeStubAssembler::Float64Trunc); | 496 MathRoundingOperation(&CodeStubAssembler::Float64Trunc); |
| 495 } | 497 } |
| 496 | 498 |
| 497 void Builtins::Generate_MathMax(MacroAssembler* masm) { | 499 // ES6 section 20.2.2.24 Math.max ( value1, value2 , ...values ) |
| 498 Generate_MathMaxMin(masm, MathMaxMinKind::kMax); | 500 TF_BUILTIN(MathMax, MathBuiltinsAssembler) { |
| 501 Label return_result(this), return_nan(this); | |
| 502 | |
| 503 Node* argc = Parameter(BuiltinDescriptor::kArgumentsCount); | |
| 504 Node* context = Parameter(BuiltinDescriptor::kContext); | |
| 505 | |
| 506 CodeStubArguments arguments(this, ChangeInt32ToIntPtr(argc)); | |
| 507 // From now on use word-size argc value. | |
| 508 argc = arguments.GetLength(); | |
| 509 | |
| 510 // If no arguments are given, the result is -infinity. | |
| 511 Variable result(this, MachineRepresentation::kFloat64); | |
| 512 result.Bind(Float64Constant(-1.0 * V8_INFINITY)); | |
| 513 GotoIf(IntPtrEqual(argc, IntPtrConstant(0)), &return_result); | |
| 514 | |
| 515 Node* nan = Float64Constant(std::numeric_limits<double>::quiet_NaN()); | |
| 516 CodeStubAssembler::VariableList vars({&result}, zone()); | |
| 517 arguments.ForEach(vars, | |
| 518 [this, context, nan, &result, &return_nan](Node* arg) { | |
| 519 Node* float_value = TruncateTaggedToFloat64(context, arg); | |
| 520 GotoIf(Float64Equal(float_value, nan), &return_nan); | |
|
vabr (Chromium)
2017/03/03 10:39:14
Interestingly, when I remove this jump, the perfor
| |
| 521 result.Bind(Float64Max(result.value(), float_value)); | |
| 522 }); | |
| 523 | |
| 524 Goto(&return_result); | |
| 525 Bind(&return_result); | |
| 526 { arguments.PopAndReturn(AllocateHeapNumberWithValue(result.value())); } | |
| 527 | |
| 528 Bind(&return_nan); | |
| 529 { arguments.PopAndReturn(AllocateHeapNumberWithValue(nan)); } | |
| 499 } | 530 } |
| 500 | 531 |
| 501 void Builtins::Generate_MathMin(MacroAssembler* masm) { | 532 void Builtins::Generate_MathMin(MacroAssembler* masm) { |
| 502 Generate_MathMaxMin(masm, MathMaxMinKind::kMin); | 533 Generate_MathMaxMin(masm, MathMaxMinKind::kMin); |
| 503 } | 534 } |
| 504 | 535 |
| 505 } // namespace internal | 536 } // namespace internal |
| 506 } // namespace v8 | 537 } // namespace v8 |
| OLD | NEW |