| 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" | 8 #include "src/code-stub-assembler.h" |
| 9 | 9 |
| 10 namespace v8 { | 10 namespace v8 { |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 Bind(&if_generic); | 329 Bind(&if_generic); |
| 330 { | 330 { |
| 331 Node* result = CallRuntime(Runtime::kStringParseInt, context, input, radix); | 331 Node* result = CallRuntime(Runtime::kStringParseInt, context, input, radix); |
| 332 Return(result); | 332 Return(result); |
| 333 } | 333 } |
| 334 } | 334 } |
| 335 | 335 |
| 336 // ES6 section 20.1.3.2 Number.prototype.toExponential ( fractionDigits ) | 336 // ES6 section 20.1.3.2 Number.prototype.toExponential ( fractionDigits ) |
| 337 BUILTIN(NumberPrototypeToExponential) { | 337 BUILTIN(NumberPrototypeToExponential) { |
| 338 HandleScope scope(isolate); | 338 HandleScope scope(isolate); |
| 339 Handle<Object> value = args.at<Object>(0); | 339 Handle<Object> value = args.at(0); |
| 340 Handle<Object> fraction_digits = args.atOrUndefined(isolate, 1); | 340 Handle<Object> fraction_digits = args.atOrUndefined(isolate, 1); |
| 341 | 341 |
| 342 // Unwrap the receiver {value}. | 342 // Unwrap the receiver {value}. |
| 343 if (value->IsJSValue()) { | 343 if (value->IsJSValue()) { |
| 344 value = handle(Handle<JSValue>::cast(value)->value(), isolate); | 344 value = handle(Handle<JSValue>::cast(value)->value(), isolate); |
| 345 } | 345 } |
| 346 if (!value->IsNumber()) { | 346 if (!value->IsNumber()) { |
| 347 THROW_NEW_ERROR_RETURN_FAILURE( | 347 THROW_NEW_ERROR_RETURN_FAILURE( |
| 348 isolate, NewTypeError(MessageTemplate::kNotGeneric, | 348 isolate, NewTypeError(MessageTemplate::kNotGeneric, |
| 349 isolate->factory()->NewStringFromAsciiChecked( | 349 isolate->factory()->NewStringFromAsciiChecked( |
| (...skipping 22 matching lines...) Expand all Loading... |
| 372 : static_cast<int>(fraction_digits_number); | 372 : static_cast<int>(fraction_digits_number); |
| 373 char* const str = DoubleToExponentialCString(value_number, f); | 373 char* const str = DoubleToExponentialCString(value_number, f); |
| 374 Handle<String> result = isolate->factory()->NewStringFromAsciiChecked(str); | 374 Handle<String> result = isolate->factory()->NewStringFromAsciiChecked(str); |
| 375 DeleteArray(str); | 375 DeleteArray(str); |
| 376 return *result; | 376 return *result; |
| 377 } | 377 } |
| 378 | 378 |
| 379 // ES6 section 20.1.3.3 Number.prototype.toFixed ( fractionDigits ) | 379 // ES6 section 20.1.3.3 Number.prototype.toFixed ( fractionDigits ) |
| 380 BUILTIN(NumberPrototypeToFixed) { | 380 BUILTIN(NumberPrototypeToFixed) { |
| 381 HandleScope scope(isolate); | 381 HandleScope scope(isolate); |
| 382 Handle<Object> value = args.at<Object>(0); | 382 Handle<Object> value = args.at(0); |
| 383 Handle<Object> fraction_digits = args.atOrUndefined(isolate, 1); | 383 Handle<Object> fraction_digits = args.atOrUndefined(isolate, 1); |
| 384 | 384 |
| 385 // Unwrap the receiver {value}. | 385 // Unwrap the receiver {value}. |
| 386 if (value->IsJSValue()) { | 386 if (value->IsJSValue()) { |
| 387 value = handle(Handle<JSValue>::cast(value)->value(), isolate); | 387 value = handle(Handle<JSValue>::cast(value)->value(), isolate); |
| 388 } | 388 } |
| 389 if (!value->IsNumber()) { | 389 if (!value->IsNumber()) { |
| 390 THROW_NEW_ERROR_RETURN_FAILURE( | 390 THROW_NEW_ERROR_RETURN_FAILURE( |
| 391 isolate, NewTypeError(MessageTemplate::kNotGeneric, | 391 isolate, NewTypeError(MessageTemplate::kNotGeneric, |
| 392 isolate->factory()->NewStringFromAsciiChecked( | 392 isolate->factory()->NewStringFromAsciiChecked( |
| (...skipping 22 matching lines...) Expand all Loading... |
| 415 char* const str = DoubleToFixedCString( | 415 char* const str = DoubleToFixedCString( |
| 416 value_number, static_cast<int>(fraction_digits_number)); | 416 value_number, static_cast<int>(fraction_digits_number)); |
| 417 Handle<String> result = isolate->factory()->NewStringFromAsciiChecked(str); | 417 Handle<String> result = isolate->factory()->NewStringFromAsciiChecked(str); |
| 418 DeleteArray(str); | 418 DeleteArray(str); |
| 419 return *result; | 419 return *result; |
| 420 } | 420 } |
| 421 | 421 |
| 422 // ES6 section 20.1.3.4 Number.prototype.toLocaleString ( [ r1 [ , r2 ] ] ) | 422 // ES6 section 20.1.3.4 Number.prototype.toLocaleString ( [ r1 [ , r2 ] ] ) |
| 423 BUILTIN(NumberPrototypeToLocaleString) { | 423 BUILTIN(NumberPrototypeToLocaleString) { |
| 424 HandleScope scope(isolate); | 424 HandleScope scope(isolate); |
| 425 Handle<Object> value = args.at<Object>(0); | 425 Handle<Object> value = args.at(0); |
| 426 | 426 |
| 427 // Unwrap the receiver {value}. | 427 // Unwrap the receiver {value}. |
| 428 if (value->IsJSValue()) { | 428 if (value->IsJSValue()) { |
| 429 value = handle(Handle<JSValue>::cast(value)->value(), isolate); | 429 value = handle(Handle<JSValue>::cast(value)->value(), isolate); |
| 430 } | 430 } |
| 431 if (!value->IsNumber()) { | 431 if (!value->IsNumber()) { |
| 432 THROW_NEW_ERROR_RETURN_FAILURE( | 432 THROW_NEW_ERROR_RETURN_FAILURE( |
| 433 isolate, NewTypeError(MessageTemplate::kNotGeneric, | 433 isolate, NewTypeError(MessageTemplate::kNotGeneric, |
| 434 isolate->factory()->NewStringFromAsciiChecked( | 434 isolate->factory()->NewStringFromAsciiChecked( |
| 435 "Number.prototype.toLocaleString"))); | 435 "Number.prototype.toLocaleString"))); |
| 436 } | 436 } |
| 437 | 437 |
| 438 // Turn the {value} into a String. | 438 // Turn the {value} into a String. |
| 439 return *isolate->factory()->NumberToString(value); | 439 return *isolate->factory()->NumberToString(value); |
| 440 } | 440 } |
| 441 | 441 |
| 442 // ES6 section 20.1.3.5 Number.prototype.toPrecision ( precision ) | 442 // ES6 section 20.1.3.5 Number.prototype.toPrecision ( precision ) |
| 443 BUILTIN(NumberPrototypeToPrecision) { | 443 BUILTIN(NumberPrototypeToPrecision) { |
| 444 HandleScope scope(isolate); | 444 HandleScope scope(isolate); |
| 445 Handle<Object> value = args.at<Object>(0); | 445 Handle<Object> value = args.at(0); |
| 446 Handle<Object> precision = args.atOrUndefined(isolate, 1); | 446 Handle<Object> precision = args.atOrUndefined(isolate, 1); |
| 447 | 447 |
| 448 // Unwrap the receiver {value}. | 448 // Unwrap the receiver {value}. |
| 449 if (value->IsJSValue()) { | 449 if (value->IsJSValue()) { |
| 450 value = handle(Handle<JSValue>::cast(value)->value(), isolate); | 450 value = handle(Handle<JSValue>::cast(value)->value(), isolate); |
| 451 } | 451 } |
| 452 if (!value->IsNumber()) { | 452 if (!value->IsNumber()) { |
| 453 THROW_NEW_ERROR_RETURN_FAILURE( | 453 THROW_NEW_ERROR_RETURN_FAILURE( |
| 454 isolate, NewTypeError(MessageTemplate::kNotGeneric, | 454 isolate, NewTypeError(MessageTemplate::kNotGeneric, |
| 455 isolate->factory()->NewStringFromAsciiChecked( | 455 isolate->factory()->NewStringFromAsciiChecked( |
| (...skipping 23 matching lines...) Expand all Loading... |
| 479 char* const str = DoubleToPrecisionCString( | 479 char* const str = DoubleToPrecisionCString( |
| 480 value_number, static_cast<int>(precision_number)); | 480 value_number, static_cast<int>(precision_number)); |
| 481 Handle<String> result = isolate->factory()->NewStringFromAsciiChecked(str); | 481 Handle<String> result = isolate->factory()->NewStringFromAsciiChecked(str); |
| 482 DeleteArray(str); | 482 DeleteArray(str); |
| 483 return *result; | 483 return *result; |
| 484 } | 484 } |
| 485 | 485 |
| 486 // ES6 section 20.1.3.6 Number.prototype.toString ( [ radix ] ) | 486 // ES6 section 20.1.3.6 Number.prototype.toString ( [ radix ] ) |
| 487 BUILTIN(NumberPrototypeToString) { | 487 BUILTIN(NumberPrototypeToString) { |
| 488 HandleScope scope(isolate); | 488 HandleScope scope(isolate); |
| 489 Handle<Object> value = args.at<Object>(0); | 489 Handle<Object> value = args.at(0); |
| 490 Handle<Object> radix = args.atOrUndefined(isolate, 1); | 490 Handle<Object> radix = args.atOrUndefined(isolate, 1); |
| 491 | 491 |
| 492 // Unwrap the receiver {value}. | 492 // Unwrap the receiver {value}. |
| 493 if (value->IsJSValue()) { | 493 if (value->IsJSValue()) { |
| 494 value = handle(Handle<JSValue>::cast(value)->value(), isolate); | 494 value = handle(Handle<JSValue>::cast(value)->value(), isolate); |
| 495 } | 495 } |
| 496 if (!value->IsNumber()) { | 496 if (!value->IsNumber()) { |
| 497 THROW_NEW_ERROR_RETURN_FAILURE( | 497 THROW_NEW_ERROR_RETURN_FAILURE( |
| 498 isolate, NewTypeError(MessageTemplate::kNotGeneric, | 498 isolate, NewTypeError(MessageTemplate::kNotGeneric, |
| 499 isolate->factory()->NewStringFromAsciiChecked( | 499 isolate->factory()->NewStringFromAsciiChecked( |
| (...skipping 1106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1606 TF_BUILTIN(StrictNotEqual, CodeStubAssembler) { | 1606 TF_BUILTIN(StrictNotEqual, CodeStubAssembler) { |
| 1607 Node* lhs = Parameter(0); | 1607 Node* lhs = Parameter(0); |
| 1608 Node* rhs = Parameter(1); | 1608 Node* rhs = Parameter(1); |
| 1609 Node* context = Parameter(2); | 1609 Node* context = Parameter(2); |
| 1610 | 1610 |
| 1611 Return(StrictEqual(kNegateResult, lhs, rhs, context)); | 1611 Return(StrictEqual(kNegateResult, lhs, rhs, context)); |
| 1612 } | 1612 } |
| 1613 | 1613 |
| 1614 } // namespace internal | 1614 } // namespace internal |
| 1615 } // namespace v8 | 1615 } // namespace v8 |
| OLD | NEW |