| 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 "src/builtins/builtins-utils.h" | 5 #include "src/builtins/builtins-utils.h" |
| 6 #include "src/builtins/builtins.h" | 6 #include "src/builtins/builtins.h" |
| 7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
| 8 #include "src/code-stub-assembler.h" | |
| 9 #include "src/compiler.h" | 8 #include "src/compiler.h" |
| 10 #include "src/counters.h" | 9 #include "src/counters.h" |
| 11 #include "src/objects-inl.h" | 10 #include "src/objects-inl.h" |
| 12 #include "src/uri.h" | 11 #include "src/uri.h" |
| 13 | 12 |
| 14 namespace v8 { | 13 namespace v8 { |
| 15 namespace internal { | 14 namespace internal { |
| 16 | 15 |
| 17 // ES6 section 18.2.6.2 decodeURI (encodedURI) | 16 // ES6 section 18.2.6.2 decodeURI (encodedURI) |
| 18 BUILTIN(GlobalDecodeURI) { | 17 BUILTIN(GlobalDecodeURI) { |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 95 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 97 isolate, function, | 96 isolate, function, |
| 98 Compiler::GetFunctionFromString(handle(target->native_context(), isolate), | 97 Compiler::GetFunctionFromString(handle(target->native_context(), isolate), |
| 99 Handle<String>::cast(x), | 98 Handle<String>::cast(x), |
| 100 NO_PARSE_RESTRICTION, kNoSourcePosition)); | 99 NO_PARSE_RESTRICTION, kNoSourcePosition)); |
| 101 RETURN_RESULT_OR_FAILURE( | 100 RETURN_RESULT_OR_FAILURE( |
| 102 isolate, | 101 isolate, |
| 103 Execution::Call(isolate, function, target_global_proxy, 0, nullptr)); | 102 Execution::Call(isolate, function, target_global_proxy, 0, nullptr)); |
| 104 } | 103 } |
| 105 | 104 |
| 106 // ES6 section 18.2.2 isFinite ( number ) | |
| 107 TF_BUILTIN(GlobalIsFinite, CodeStubAssembler) { | |
| 108 Node* context = Parameter(4); | |
| 109 | |
| 110 Label return_true(this), return_false(this); | |
| 111 | |
| 112 // We might need to loop once for ToNumber conversion. | |
| 113 Variable var_num(this, MachineRepresentation::kTagged); | |
| 114 Label loop(this, &var_num); | |
| 115 var_num.Bind(Parameter(1)); | |
| 116 Goto(&loop); | |
| 117 Bind(&loop); | |
| 118 { | |
| 119 Node* num = var_num.value(); | |
| 120 | |
| 121 // Check if {num} is a Smi or a HeapObject. | |
| 122 GotoIf(TaggedIsSmi(num), &return_true); | |
| 123 | |
| 124 // Check if {num} is a HeapNumber. | |
| 125 Label if_numisheapnumber(this), | |
| 126 if_numisnotheapnumber(this, Label::kDeferred); | |
| 127 Branch(IsHeapNumberMap(LoadMap(num)), &if_numisheapnumber, | |
| 128 &if_numisnotheapnumber); | |
| 129 | |
| 130 Bind(&if_numisheapnumber); | |
| 131 { | |
| 132 // Check if {num} contains a finite, non-NaN value. | |
| 133 Node* num_value = LoadHeapNumberValue(num); | |
| 134 BranchIfFloat64IsNaN(Float64Sub(num_value, num_value), &return_false, | |
| 135 &return_true); | |
| 136 } | |
| 137 | |
| 138 Bind(&if_numisnotheapnumber); | |
| 139 { | |
| 140 // Need to convert {num} to a Number first. | |
| 141 Callable callable = CodeFactory::NonNumberToNumber(isolate()); | |
| 142 var_num.Bind(CallStub(callable, context, num)); | |
| 143 Goto(&loop); | |
| 144 } | |
| 145 } | |
| 146 | |
| 147 Bind(&return_true); | |
| 148 Return(BooleanConstant(true)); | |
| 149 | |
| 150 Bind(&return_false); | |
| 151 Return(BooleanConstant(false)); | |
| 152 } | |
| 153 | |
| 154 // ES6 section 18.2.3 isNaN ( number ) | |
| 155 TF_BUILTIN(GlobalIsNaN, CodeStubAssembler) { | |
| 156 Node* context = Parameter(4); | |
| 157 | |
| 158 Label return_true(this), return_false(this); | |
| 159 | |
| 160 // We might need to loop once for ToNumber conversion. | |
| 161 Variable var_num(this, MachineRepresentation::kTagged); | |
| 162 Label loop(this, &var_num); | |
| 163 var_num.Bind(Parameter(1)); | |
| 164 Goto(&loop); | |
| 165 Bind(&loop); | |
| 166 { | |
| 167 Node* num = var_num.value(); | |
| 168 | |
| 169 // Check if {num} is a Smi or a HeapObject. | |
| 170 GotoIf(TaggedIsSmi(num), &return_false); | |
| 171 | |
| 172 // Check if {num} is a HeapNumber. | |
| 173 Label if_numisheapnumber(this), | |
| 174 if_numisnotheapnumber(this, Label::kDeferred); | |
| 175 Branch(IsHeapNumberMap(LoadMap(num)), &if_numisheapnumber, | |
| 176 &if_numisnotheapnumber); | |
| 177 | |
| 178 Bind(&if_numisheapnumber); | |
| 179 { | |
| 180 // Check if {num} contains a NaN. | |
| 181 Node* num_value = LoadHeapNumberValue(num); | |
| 182 BranchIfFloat64IsNaN(num_value, &return_true, &return_false); | |
| 183 } | |
| 184 | |
| 185 Bind(&if_numisnotheapnumber); | |
| 186 { | |
| 187 // Need to convert {num} to a Number first. | |
| 188 Callable callable = CodeFactory::NonNumberToNumber(isolate()); | |
| 189 var_num.Bind(CallStub(callable, context, num)); | |
| 190 Goto(&loop); | |
| 191 } | |
| 192 } | |
| 193 | |
| 194 Bind(&return_true); | |
| 195 Return(BooleanConstant(true)); | |
| 196 | |
| 197 Bind(&return_false); | |
| 198 Return(BooleanConstant(false)); | |
| 199 } | |
| 200 | |
| 201 } // namespace internal | 105 } // namespace internal |
| 202 } // namespace v8 | 106 } // namespace v8 |
| OLD | NEW |