Commit 62bd294f authored by machenbach's avatar machenbach Committed by Commit bot

Revert of Wrap runtime.js in a function. (patchset #2 id:20001 of...

Revert of Wrap runtime.js in a function. (patchset #2 id:20001 of https://codereview.chromium.org/1126213002/)

Reason for revert:
[Sheriff] Breaks nosnap:
http://build.chromium.org/p/client.v8/builders/V8%20Linux%20-%20nosnap/builds/2872

Original issue's description:
> Wrap runtime.js in a function.
>
> R=jkummerow@chromium.org
>
> Committed: https://crrev.com/65c56d49b2d671ac9e379de726bff3eb03a508c1
> Cr-Commit-Position: refs/heads/master@{#28275}

TBR=jkummerow@chromium.org,yangguo@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true

Review URL: https://codereview.chromium.org/1123353004

Cr-Commit-Position: refs/heads/master@{#28277}
parent addbe75e
...@@ -47,7 +47,7 @@ function ArrayIterator() {} ...@@ -47,7 +47,7 @@ function ArrayIterator() {}
// 15.4.5.1 CreateArrayIterator Abstract Operation // 15.4.5.1 CreateArrayIterator Abstract Operation
function CreateArrayIterator(array, kind) { function CreateArrayIterator(array, kind) {
var object = $toObject(array); var object = ToObject(array);
var iterator = new ArrayIterator; var iterator = new ArrayIterator;
SET_PRIVATE(iterator, arrayIteratorObjectSymbol, object); SET_PRIVATE(iterator, arrayIteratorObjectSymbol, object);
SET_PRIVATE(iterator, arrayIteratorNextIndexSymbol, 0); SET_PRIVATE(iterator, arrayIteratorNextIndexSymbol, 0);
...@@ -70,7 +70,7 @@ function ArrayIteratorIterator() { ...@@ -70,7 +70,7 @@ function ArrayIteratorIterator() {
// 15.4.5.2.2 ArrayIterator.prototype.next( ) // 15.4.5.2.2 ArrayIterator.prototype.next( )
function ArrayIteratorNext() { function ArrayIteratorNext() {
var iterator = $toObject(this); var iterator = ToObject(this);
if (!HAS_DEFINED_PRIVATE(iterator, arrayIteratorNextIndexSymbol)) { if (!HAS_DEFINED_PRIVATE(iterator, arrayIteratorNextIndexSymbol)) {
throw MakeTypeError(kIncompatibleMethodReceiver, throw MakeTypeError(kIncompatibleMethodReceiver,
......
...@@ -196,7 +196,7 @@ function ConvertToString(x) { ...@@ -196,7 +196,7 @@ function ConvertToString(x) {
// Assumes x is a non-string. // Assumes x is a non-string.
if (IS_NUMBER(x)) return %_NumberToString(x); if (IS_NUMBER(x)) return %_NumberToString(x);
if (IS_BOOLEAN(x)) return x ? 'true' : 'false'; if (IS_BOOLEAN(x)) return x ? 'true' : 'false';
return (IS_NULL_OR_UNDEFINED(x)) ? '' : $toString($defaultString(x)); return (IS_NULL_OR_UNDEFINED(x)) ? '' : %ToString(%DefaultString(x));
} }
...@@ -207,8 +207,8 @@ function ConvertToLocaleString(e) { ...@@ -207,8 +207,8 @@ function ConvertToLocaleString(e) {
// According to ES5, section 15.4.4.3, the toLocaleString conversion // According to ES5, section 15.4.4.3, the toLocaleString conversion
// must throw a TypeError if ToObject(e).toLocaleString isn't // must throw a TypeError if ToObject(e).toLocaleString isn't
// callable. // callable.
var e_obj = $toObject(e); var e_obj = ToObject(e);
return $toString(e_obj.toLocaleString()); return %ToString(e_obj.toLocaleString());
} }
} }
...@@ -368,7 +368,7 @@ function ArrayToString() { ...@@ -368,7 +368,7 @@ function ArrayToString() {
} }
array = this; array = this;
} else { } else {
array = $toObject(this); array = ToObject(this);
func = array.join; func = array.join;
} }
if (!IS_SPEC_FUNCTION(func)) { if (!IS_SPEC_FUNCTION(func)) {
...@@ -379,7 +379,7 @@ function ArrayToString() { ...@@ -379,7 +379,7 @@ function ArrayToString() {
function ArrayToLocaleString() { function ArrayToLocaleString() {
var array = $toObject(this); var array = ToObject(this);
var arrayLen = array.length; var arrayLen = array.length;
var len = TO_UINT32(arrayLen); var len = TO_UINT32(arrayLen);
if (len === 0) return ""; if (len === 0) return "";
...@@ -395,7 +395,7 @@ function ArrayJoin(separator) { ...@@ -395,7 +395,7 @@ function ArrayJoin(separator) {
if (IS_UNDEFINED(separator)) { if (IS_UNDEFINED(separator)) {
separator = ','; separator = ',';
} else if (!IS_STRING(separator)) { } else if (!IS_STRING(separator)) {
separator = $nonStringToString(separator); separator = NonStringToString(separator);
} }
var result = %_FastOneByteArrayJoin(array, separator); var result = %_FastOneByteArrayJoin(array, separator);
...@@ -406,7 +406,7 @@ function ArrayJoin(separator) { ...@@ -406,7 +406,7 @@ function ArrayJoin(separator) {
var e = array[0]; var e = array[0];
if (IS_STRING(e)) return e; if (IS_STRING(e)) return e;
if (IS_NULL_OR_UNDEFINED(e)) return ''; if (IS_NULL_OR_UNDEFINED(e)) return '';
return $nonStringToString(e); return NonStringToString(e);
} }
return Join(array, length, separator, ConvertToString); return Join(array, length, separator, ConvertToString);
...@@ -447,7 +447,7 @@ function ArrayPop() { ...@@ -447,7 +447,7 @@ function ArrayPop() {
n--; n--;
var value = array[n]; var value = array[n];
$delete(array, $toName(n), true); $delete(array, ToName(n), true);
array.length = n; array.length = n;
return value; return value;
} }
...@@ -501,7 +501,7 @@ function ArrayPush() { ...@@ -501,7 +501,7 @@ function ArrayPush() {
function ArrayConcatJS(arg1) { // length == 1 function ArrayConcatJS(arg1) { // length == 1
CHECK_OBJECT_COERCIBLE(this, "Array.prototype.concat"); CHECK_OBJECT_COERCIBLE(this, "Array.prototype.concat");
var array = $toObject(this); var array = ToObject(this);
var arg_count = %_ArgumentsLength(); var arg_count = %_ArgumentsLength();
var arrays = new InternalArray(1 + arg_count); var arrays = new InternalArray(1 + arg_count);
arrays[0] = array; arrays[0] = array;
...@@ -866,8 +866,8 @@ function ArraySort(comparefn) { ...@@ -866,8 +866,8 @@ function ArraySort(comparefn) {
if (%_IsSmi(x) && %_IsSmi(y)) { if (%_IsSmi(x) && %_IsSmi(y)) {
return %SmiLexicographicCompare(x, y); return %SmiLexicographicCompare(x, y);
} }
x = $toString(x); x = ToString(x);
y = $toString(y); y = ToString(y);
if (x == y) return 0; if (x == y) return 0;
else return x < y ? -1 : 1; else return x < y ? -1 : 1;
}; };
...@@ -1148,8 +1148,8 @@ function ArrayFilter(f, receiver) { ...@@ -1148,8 +1148,8 @@ function ArrayFilter(f, receiver) {
// Pull out the length so that modifications to the length in the // Pull out the length so that modifications to the length in the
// loop will not affect the looping and side effects are visible. // loop will not affect the looping and side effects are visible.
var array = $toObject(this); var array = ToObject(this);
var length = $toUint32(array.length); var length = ToUint32(array.length);
if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f); if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f);
var needs_wrapper = false; var needs_wrapper = false;
...@@ -1169,7 +1169,7 @@ function ArrayFilter(f, receiver) { ...@@ -1169,7 +1169,7 @@ function ArrayFilter(f, receiver) {
var element = array[i]; var element = array[i];
// Prepare break slots for debugger step in. // Prepare break slots for debugger step in.
if (stepping) %DebugPrepareStepInIfStepping(f); if (stepping) %DebugPrepareStepInIfStepping(f);
var new_receiver = needs_wrapper ? $toObject(receiver) : receiver; var new_receiver = needs_wrapper ? ToObject(receiver) : receiver;
if (%_CallFunction(new_receiver, element, i, array, f)) { if (%_CallFunction(new_receiver, element, i, array, f)) {
accumulator[accumulator_length++] = element; accumulator[accumulator_length++] = element;
} }
...@@ -1185,7 +1185,7 @@ function ArrayForEach(f, receiver) { ...@@ -1185,7 +1185,7 @@ function ArrayForEach(f, receiver) {
// Pull out the length so that modifications to the length in the // Pull out the length so that modifications to the length in the
// loop will not affect the looping and side effects are visible. // loop will not affect the looping and side effects are visible.
var array = $toObject(this); var array = ToObject(this);
var length = TO_UINT32(array.length); var length = TO_UINT32(array.length);
if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f); if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f);
...@@ -1203,7 +1203,7 @@ function ArrayForEach(f, receiver) { ...@@ -1203,7 +1203,7 @@ function ArrayForEach(f, receiver) {
var element = array[i]; var element = array[i];
// Prepare break slots for debugger step in. // Prepare break slots for debugger step in.
if (stepping) %DebugPrepareStepInIfStepping(f); if (stepping) %DebugPrepareStepInIfStepping(f);
var new_receiver = needs_wrapper ? $toObject(receiver) : receiver; var new_receiver = needs_wrapper ? ToObject(receiver) : receiver;
%_CallFunction(new_receiver, element, i, array, f); %_CallFunction(new_receiver, element, i, array, f);
} }
} }
...@@ -1217,7 +1217,7 @@ function ArraySome(f, receiver) { ...@@ -1217,7 +1217,7 @@ function ArraySome(f, receiver) {
// Pull out the length so that modifications to the length in the // Pull out the length so that modifications to the length in the
// loop will not affect the looping and side effects are visible. // loop will not affect the looping and side effects are visible.
var array = $toObject(this); var array = ToObject(this);
var length = TO_UINT32(array.length); var length = TO_UINT32(array.length);
if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f); if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f);
...@@ -1235,7 +1235,7 @@ function ArraySome(f, receiver) { ...@@ -1235,7 +1235,7 @@ function ArraySome(f, receiver) {
var element = array[i]; var element = array[i];
// Prepare break slots for debugger step in. // Prepare break slots for debugger step in.
if (stepping) %DebugPrepareStepInIfStepping(f); if (stepping) %DebugPrepareStepInIfStepping(f);
var new_receiver = needs_wrapper ? $toObject(receiver) : receiver; var new_receiver = needs_wrapper ? ToObject(receiver) : receiver;
if (%_CallFunction(new_receiver, element, i, array, f)) return true; if (%_CallFunction(new_receiver, element, i, array, f)) return true;
} }
} }
...@@ -1248,7 +1248,7 @@ function ArrayEvery(f, receiver) { ...@@ -1248,7 +1248,7 @@ function ArrayEvery(f, receiver) {
// Pull out the length so that modifications to the length in the // Pull out the length so that modifications to the length in the
// loop will not affect the looping and side effects are visible. // loop will not affect the looping and side effects are visible.
var array = $toObject(this); var array = ToObject(this);
var length = TO_UINT32(array.length); var length = TO_UINT32(array.length);
if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f); if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f);
...@@ -1266,7 +1266,7 @@ function ArrayEvery(f, receiver) { ...@@ -1266,7 +1266,7 @@ function ArrayEvery(f, receiver) {
var element = array[i]; var element = array[i];
// Prepare break slots for debugger step in. // Prepare break slots for debugger step in.
if (stepping) %DebugPrepareStepInIfStepping(f); if (stepping) %DebugPrepareStepInIfStepping(f);
var new_receiver = needs_wrapper ? $toObject(receiver) : receiver; var new_receiver = needs_wrapper ? ToObject(receiver) : receiver;
if (!%_CallFunction(new_receiver, element, i, array, f)) return false; if (!%_CallFunction(new_receiver, element, i, array, f)) return false;
} }
} }
...@@ -1279,7 +1279,7 @@ function ArrayMap(f, receiver) { ...@@ -1279,7 +1279,7 @@ function ArrayMap(f, receiver) {
// Pull out the length so that modifications to the length in the // Pull out the length so that modifications to the length in the
// loop will not affect the looping and side effects are visible. // loop will not affect the looping and side effects are visible.
var array = $toObject(this); var array = ToObject(this);
var length = TO_UINT32(array.length); var length = TO_UINT32(array.length);
if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f); if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f);
...@@ -1299,7 +1299,7 @@ function ArrayMap(f, receiver) { ...@@ -1299,7 +1299,7 @@ function ArrayMap(f, receiver) {
var element = array[i]; var element = array[i];
// Prepare break slots for debugger step in. // Prepare break slots for debugger step in.
if (stepping) %DebugPrepareStepInIfStepping(f); if (stepping) %DebugPrepareStepInIfStepping(f);
var new_receiver = needs_wrapper ? $toObject(receiver) : receiver; var new_receiver = needs_wrapper ? ToObject(receiver) : receiver;
accumulator[i] = %_CallFunction(new_receiver, element, i, array, f); accumulator[i] = %_CallFunction(new_receiver, element, i, array, f);
} }
} }
...@@ -1423,8 +1423,8 @@ function ArrayReduce(callback, current) { ...@@ -1423,8 +1423,8 @@ function ArrayReduce(callback, current) {
// Pull out the length so that modifications to the length in the // Pull out the length so that modifications to the length in the
// loop will not affect the looping and side effects are visible. // loop will not affect the looping and side effects are visible.
var array = $toObject(this); var array = ToObject(this);
var length = $toUint32(array.length); var length = ToUint32(array.length);
if (!IS_SPEC_FUNCTION(callback)) { if (!IS_SPEC_FUNCTION(callback)) {
throw MakeTypeError(kCalledNonCallable, callback); throw MakeTypeError(kCalledNonCallable, callback);
...@@ -1460,8 +1460,8 @@ function ArrayReduceRight(callback, current) { ...@@ -1460,8 +1460,8 @@ function ArrayReduceRight(callback, current) {
// Pull out the length so that side effects are visible before the // Pull out the length so that side effects are visible before the
// callback function is checked. // callback function is checked.
var array = $toObject(this); var array = ToObject(this);
var length = $toUint32(array.length); var length = ToUint32(array.length);
if (!IS_SPEC_FUNCTION(callback)) { if (!IS_SPEC_FUNCTION(callback)) {
throw MakeTypeError(kCalledNonCallable, callback); throw MakeTypeError(kCalledNonCallable, callback);
......
...@@ -15,7 +15,7 @@ var GlobalObject = global.Object; ...@@ -15,7 +15,7 @@ var GlobalObject = global.Object;
function ArrayBufferConstructor(length) { // length = 1 function ArrayBufferConstructor(length) { // length = 1
if (%_IsConstructCall()) { if (%_IsConstructCall()) {
var byteLength = $toPositiveInteger(length, kInvalidArrayBufferLength); var byteLength = ToPositiveInteger(length, kInvalidArrayBufferLength);
%ArrayBufferInitialize(this, byteLength); %ArrayBufferInitialize(this, byteLength);
} else { } else {
throw MakeTypeError(kConstructorNotFunction, "ArrayBuffer"); throw MakeTypeError(kConstructorNotFunction, "ArrayBuffer");
......
...@@ -264,7 +264,7 @@ class AstValue : public ZoneObject { ...@@ -264,7 +264,7 @@ class AstValue : public ZoneObject {
F(spread_iterable, "$spreadIterable") \ F(spread_iterable, "$spreadIterable") \
F(this, "this") \ F(this, "this") \
F(throw_iterator_result_not_an_object, "ThrowIteratorResultNotAnObject") \ F(throw_iterator_result_not_an_object, "ThrowIteratorResultNotAnObject") \
F(to_string, "$toString") \ F(to_string, "ToString") \
F(undefined, "undefined") \ F(undefined, "undefined") \
F(use_asm, "use asm") \ F(use_asm, "use asm") \
F(use_strong, "use strong") \ F(use_strong, "use strong") \
......
...@@ -1564,14 +1564,14 @@ void Genesis::InstallNativeFunctions() { ...@@ -1564,14 +1564,14 @@ void Genesis::InstallNativeFunctions() {
HandleScope scope(isolate()); HandleScope scope(isolate());
INSTALL_NATIVE(JSFunction, "$createDate", create_date_fun); INSTALL_NATIVE(JSFunction, "$createDate", create_date_fun);
INSTALL_NATIVE(JSFunction, "$toNumber", to_number_fun); INSTALL_NATIVE(JSFunction, "ToNumber", to_number_fun);
INSTALL_NATIVE(JSFunction, "$toString", to_string_fun); INSTALL_NATIVE(JSFunction, "ToString", to_string_fun);
INSTALL_NATIVE(JSFunction, "$toDetailString", to_detail_string_fun); INSTALL_NATIVE(JSFunction, "$toDetailString", to_detail_string_fun);
INSTALL_NATIVE(JSFunction, "$toObject", to_object_fun); INSTALL_NATIVE(JSFunction, "ToObject", to_object_fun);
INSTALL_NATIVE(JSFunction, "$toInteger", to_integer_fun); INSTALL_NATIVE(JSFunction, "ToInteger", to_integer_fun);
INSTALL_NATIVE(JSFunction, "$toUint32", to_uint32_fun); INSTALL_NATIVE(JSFunction, "ToUint32", to_uint32_fun);
INSTALL_NATIVE(JSFunction, "$toInt32", to_int32_fun); INSTALL_NATIVE(JSFunction, "ToInt32", to_int32_fun);
INSTALL_NATIVE(JSFunction, "$toLength", to_length_fun); INSTALL_NATIVE(JSFunction, "ToLength", to_length_fun);
INSTALL_NATIVE(JSFunction, "$globalEval", global_eval_fun); INSTALL_NATIVE(JSFunction, "$globalEval", global_eval_fun);
INSTALL_NATIVE(JSFunction, "$getStackTraceLine", get_stack_trace_line_fun); INSTALL_NATIVE(JSFunction, "$getStackTraceLine", get_stack_trace_line_fun);
......
...@@ -222,7 +222,7 @@ function SetForEach(f, receiver) { ...@@ -222,7 +222,7 @@ function SetForEach(f, receiver) {
while (%SetIteratorNext(iterator, value_array)) { while (%SetIteratorNext(iterator, value_array)) {
if (stepping) %DebugPrepareStepInIfStepping(f); if (stepping) %DebugPrepareStepInIfStepping(f);
key = value_array[0]; key = value_array[0];
var new_receiver = needs_wrapper ? $toObject(receiver) : receiver; var new_receiver = needs_wrapper ? ToObject(receiver) : receiver;
%_CallFunction(new_receiver, key, key, this, f); %_CallFunction(new_receiver, key, key, this, f);
} }
} }
...@@ -410,7 +410,7 @@ function MapForEach(f, receiver) { ...@@ -410,7 +410,7 @@ function MapForEach(f, receiver) {
var value_array = [UNDEFINED, UNDEFINED]; var value_array = [UNDEFINED, UNDEFINED];
while (%MapIteratorNext(iterator, value_array)) { while (%MapIteratorNext(iterator, value_array)) {
if (stepping) %DebugPrepareStepInIfStepping(f); if (stepping) %DebugPrepareStepInIfStepping(f);
var new_receiver = needs_wrapper ? $toObject(receiver) : receiver; var new_receiver = needs_wrapper ? ToObject(receiver) : receiver;
%_CallFunction(new_receiver, value_array[1], value_array[0], this, f); %_CallFunction(new_receiver, value_array[1], value_array[0], this, f);
} }
} }
......
This diff is collapsed.
...@@ -202,8 +202,7 @@ BreakPoint.prototype.isTriggered = function(exec_state) { ...@@ -202,8 +202,7 @@ BreakPoint.prototype.isTriggered = function(exec_state) {
try { try {
var mirror = exec_state.frame(0).evaluate(this.condition()); var mirror = exec_state.frame(0).evaluate(this.condition());
// If no sensible mirror or non true value break point not triggered. // If no sensible mirror or non true value break point not triggered.
if (!(mirror instanceof ValueMirror) || if (!(mirror instanceof ValueMirror) || !%ToBoolean(mirror.value_)) {
!builtins.$toBoolean(mirror.value_)) {
return false; return false;
} }
} catch (e) { } catch (e) {
...@@ -925,8 +924,8 @@ function ExecutionState(break_id) { ...@@ -925,8 +924,8 @@ function ExecutionState(break_id) {
ExecutionState.prototype.prepareStep = function(opt_action, opt_count, ExecutionState.prototype.prepareStep = function(opt_action, opt_count,
opt_callframe) { opt_callframe) {
var action = Debug.StepAction.StepIn; var action = Debug.StepAction.StepIn;
if (!IS_UNDEFINED(opt_action)) action = builtins.$toNumber(opt_action); if (!IS_UNDEFINED(opt_action)) action = %ToNumber(opt_action);
var count = opt_count ? builtins.$toNumber(opt_count) : 1; var count = opt_count ? %ToNumber(opt_count) : 1;
var callFrameId = 0; var callFrameId = 0;
if (!IS_UNDEFINED(opt_callframe)) { if (!IS_UNDEFINED(opt_callframe)) {
callFrameId = opt_callframe.details_.frameId(); callFrameId = opt_callframe.details_.frameId();
...@@ -960,7 +959,7 @@ ExecutionState.prototype.frame = function(opt_index) { ...@@ -960,7 +959,7 @@ ExecutionState.prototype.frame = function(opt_index) {
}; };
ExecutionState.prototype.setSelectedFrame = function(index) { ExecutionState.prototype.setSelectedFrame = function(index) {
var i = builtins.$toNumber(index); var i = %ToNumber(index);
if (i < 0 || i >= this.frameCount()) throw new Error('Illegal frame index.'); if (i < 0 || i >= this.frameCount()) throw new Error('Illegal frame index.');
this.selected_frame = i; this.selected_frame = i;
}; };
...@@ -1403,7 +1402,7 @@ DebugCommandProcessor.prototype.processDebugJSONRequest = function( ...@@ -1403,7 +1402,7 @@ DebugCommandProcessor.prototype.processDebugJSONRequest = function(
response = this.createResponse(); response = this.createResponse();
} }
response.success = false; response.success = false;
response.message = builtins.$toString(e); response.message = %ToString(e);
} }
// Return the response as a JSON encoded string. // Return the response as a JSON encoded string.
...@@ -1420,7 +1419,7 @@ DebugCommandProcessor.prototype.processDebugJSONRequest = function( ...@@ -1420,7 +1419,7 @@ DebugCommandProcessor.prototype.processDebugJSONRequest = function(
'"request_seq":' + request.seq + ',' + '"request_seq":' + request.seq + ',' +
'"type":"response",' + '"type":"response",' +
'"success":false,' + '"success":false,' +
'"message":"Internal error: ' + builtins.$toString(e) + '"}'; '"message":"Internal error: ' + %ToString(e) + '"}';
} }
} catch (e) { } catch (e) {
// Failed in one of the catch blocks above - most generic error. // Failed in one of the catch blocks above - most generic error.
...@@ -1441,7 +1440,7 @@ DebugCommandProcessor.prototype.continueRequest_ = function(request, response) { ...@@ -1441,7 +1440,7 @@ DebugCommandProcessor.prototype.continueRequest_ = function(request, response) {
// Get the stepcount argument if any. // Get the stepcount argument if any.
if (stepcount) { if (stepcount) {
count = builtins.$toNumber(stepcount); count = %ToNumber(stepcount);
if (count < 0) { if (count < 0) {
throw new Error('Invalid stepcount argument "' + stepcount + '".'); throw new Error('Invalid stepcount argument "' + stepcount + '".');
} }
...@@ -1514,7 +1513,7 @@ DebugCommandProcessor.prototype.setBreakPointRequest_ = ...@@ -1514,7 +1513,7 @@ DebugCommandProcessor.prototype.setBreakPointRequest_ =
// Find the function through a global evaluate. // Find the function through a global evaluate.
f = this.exec_state_.evaluateGlobal(target).value(); f = this.exec_state_.evaluateGlobal(target).value();
} catch (e) { } catch (e) {
response.failed('Error: "' + builtins.$toString(e) + response.failed('Error: "' + %ToString(e) +
'" evaluating "' + target + '"'); '" evaluating "' + target + '"');
return; return;
} }
...@@ -1603,7 +1602,7 @@ DebugCommandProcessor.prototype.changeBreakPointRequest_ = function( ...@@ -1603,7 +1602,7 @@ DebugCommandProcessor.prototype.changeBreakPointRequest_ = function(
} }
// Pull out arguments. // Pull out arguments.
var break_point = builtins.$toNumber(request.arguments.breakpoint); var break_point = %ToNumber(request.arguments.breakpoint);
var enabled = request.arguments.enabled; var enabled = request.arguments.enabled;
var condition = request.arguments.condition; var condition = request.arguments.condition;
var ignoreCount = request.arguments.ignoreCount; var ignoreCount = request.arguments.ignoreCount;
...@@ -1679,7 +1678,7 @@ DebugCommandProcessor.prototype.clearBreakPointRequest_ = function( ...@@ -1679,7 +1678,7 @@ DebugCommandProcessor.prototype.clearBreakPointRequest_ = function(
} }
// Pull out arguments. // Pull out arguments.
var break_point = builtins.$toNumber(request.arguments.breakpoint); var break_point = %ToNumber(request.arguments.breakpoint);
// Check for legal arguments. // Check for legal arguments.
if (!break_point) { if (!break_point) {
...@@ -1936,7 +1935,7 @@ DebugCommandProcessor.prototype.scopeRequest_ = function(request, response) { ...@@ -1936,7 +1935,7 @@ DebugCommandProcessor.prototype.scopeRequest_ = function(request, response) {
// With no scope argument just return top scope. // With no scope argument just return top scope.
var scope_index = 0; var scope_index = 0;
if (request.arguments && !IS_UNDEFINED(request.arguments.number)) { if (request.arguments && !IS_UNDEFINED(request.arguments.number)) {
scope_index = builtins.$toNumber(request.arguments.number); scope_index = %ToNumber(request.arguments.number);
if (scope_index < 0 || scope_holder.scopeCount() <= scope_index) { if (scope_index < 0 || scope_holder.scopeCount() <= scope_index) {
return response.failed('Invalid scope number'); return response.failed('Invalid scope number');
} }
...@@ -2000,7 +1999,7 @@ DebugCommandProcessor.prototype.setVariableValueRequest_ = ...@@ -2000,7 +1999,7 @@ DebugCommandProcessor.prototype.setVariableValueRequest_ =
if (IS_UNDEFINED(scope_description.number)) { if (IS_UNDEFINED(scope_description.number)) {
response.failed('Missing scope number'); response.failed('Missing scope number');
} }
var scope_index = builtins.$toNumber(scope_description.number); var scope_index = %ToNumber(scope_description.number);
var scope = scope_holder.scope(scope_index); var scope = scope_holder.scope(scope_index);
...@@ -2078,7 +2077,7 @@ DebugCommandProcessor.prototype.evaluateRequest_ = function(request, response) { ...@@ -2078,7 +2077,7 @@ DebugCommandProcessor.prototype.evaluateRequest_ = function(request, response) {
// Check whether a frame was specified. // Check whether a frame was specified.
if (!IS_UNDEFINED(frame)) { if (!IS_UNDEFINED(frame)) {
var frame_number = builtins.$toNumber(frame); var frame_number = %ToNumber(frame);
if (frame_number < 0 || frame_number >= this.exec_state_.frameCount()) { if (frame_number < 0 || frame_number >= this.exec_state_.frameCount()) {
return response.failed('Invalid frame "' + frame + '"'); return response.failed('Invalid frame "' + frame + '"');
} }
...@@ -2110,7 +2109,7 @@ DebugCommandProcessor.prototype.lookupRequest_ = function(request, response) { ...@@ -2110,7 +2109,7 @@ DebugCommandProcessor.prototype.lookupRequest_ = function(request, response) {
// Set 'includeSource' option for script lookup. // Set 'includeSource' option for script lookup.
if (!IS_UNDEFINED(request.arguments.includeSource)) { if (!IS_UNDEFINED(request.arguments.includeSource)) {
var includeSource = builtins.$toBoolean(request.arguments.includeSource); var includeSource = %ToBoolean(request.arguments.includeSource);
response.setOption('includeSource', includeSource); response.setOption('includeSource', includeSource);
} }
...@@ -2178,7 +2177,7 @@ DebugCommandProcessor.prototype.sourceRequest_ = function(request, response) { ...@@ -2178,7 +2177,7 @@ DebugCommandProcessor.prototype.sourceRequest_ = function(request, response) {
to_line = request.arguments.toLine; to_line = request.arguments.toLine;
if (!IS_UNDEFINED(request.arguments.frame)) { if (!IS_UNDEFINED(request.arguments.frame)) {
var frame_number = builtins.$toNumber(request.arguments.frame); var frame_number = %ToNumber(request.arguments.frame);
if (frame_number < 0 || frame_number >= this.exec_state_.frameCount()) { if (frame_number < 0 || frame_number >= this.exec_state_.frameCount()) {
return response.failed('Invalid frame "' + frame + '"'); return response.failed('Invalid frame "' + frame + '"');
} }
...@@ -2214,7 +2213,7 @@ DebugCommandProcessor.prototype.scriptsRequest_ = function(request, response) { ...@@ -2214,7 +2213,7 @@ DebugCommandProcessor.prototype.scriptsRequest_ = function(request, response) {
if (request.arguments) { if (request.arguments) {
// Pull out arguments. // Pull out arguments.
if (!IS_UNDEFINED(request.arguments.types)) { if (!IS_UNDEFINED(request.arguments.types)) {
types = builtins.$toNumber(request.arguments.types); types = %ToNumber(request.arguments.types);
if (isNaN(types) || types < 0) { if (isNaN(types) || types < 0) {
return response.failed('Invalid types "' + return response.failed('Invalid types "' +
request.arguments.types + '"'); request.arguments.types + '"');
...@@ -2222,7 +2221,7 @@ DebugCommandProcessor.prototype.scriptsRequest_ = function(request, response) { ...@@ -2222,7 +2221,7 @@ DebugCommandProcessor.prototype.scriptsRequest_ = function(request, response) {
} }
if (!IS_UNDEFINED(request.arguments.includeSource)) { if (!IS_UNDEFINED(request.arguments.includeSource)) {
includeSource = builtins.$toBoolean(request.arguments.includeSource); includeSource = %ToBoolean(request.arguments.includeSource);
response.setOption('includeSource', includeSource); response.setOption('includeSource', includeSource);
} }
...@@ -2237,7 +2236,7 @@ DebugCommandProcessor.prototype.scriptsRequest_ = function(request, response) { ...@@ -2237,7 +2236,7 @@ DebugCommandProcessor.prototype.scriptsRequest_ = function(request, response) {
var filterStr = null; var filterStr = null;
var filterNum = null; var filterNum = null;
if (!IS_UNDEFINED(request.arguments.filter)) { if (!IS_UNDEFINED(request.arguments.filter)) {
var num = builtins.$toNumber(request.arguments.filter); var num = %ToNumber(request.arguments.filter);
if (!isNaN(num)) { if (!isNaN(num)) {
filterNum = num; filterNum = num;
} }
...@@ -2373,7 +2372,7 @@ DebugCommandProcessor.prototype.restartFrameRequest_ = function( ...@@ -2373,7 +2372,7 @@ DebugCommandProcessor.prototype.restartFrameRequest_ = function(
var frame_mirror; var frame_mirror;
// Check whether a frame was specified. // Check whether a frame was specified.
if (!IS_UNDEFINED(frame)) { if (!IS_UNDEFINED(frame)) {
var frame_number = builtins.$toNumber(frame); var frame_number = %ToNumber(frame);
if (frame_number < 0 || frame_number >= this.exec_state_.frameCount()) { if (frame_number < 0 || frame_number >= this.exec_state_.frameCount()) {
return response.failed('Invalid frame "' + frame + '"'); return response.failed('Invalid frame "' + frame + '"');
} }
......
...@@ -16,14 +16,14 @@ var GlobalArray = global.Array; ...@@ -16,14 +16,14 @@ var GlobalArray = global.Array;
// https://github.com/tc39/Array.prototype.includes // https://github.com/tc39/Array.prototype.includes
// 6e3b78c927aeda20b9d40e81303f9d44596cd904 // 6e3b78c927aeda20b9d40e81303f9d44596cd904
function ArrayIncludes(searchElement, fromIndex) { function ArrayIncludes(searchElement, fromIndex) {
var array = $toObject(this); var array = ToObject(this);
var len = $toLength(array.length); var len = ToLength(array.length);
if (len === 0) { if (len === 0) {
return false; return false;
} }
var n = $toInteger(fromIndex); var n = ToInteger(fromIndex);
var k; var k;
if (n >= 0) { if (n >= 0) {
...@@ -37,7 +37,7 @@ function ArrayIncludes(searchElement, fromIndex) { ...@@ -37,7 +37,7 @@ function ArrayIncludes(searchElement, fromIndex) {
while (k < len) { while (k < len) {
var elementK = array[k]; var elementK = array[k];
if ($sameValueZero(searchElement, elementK)) { if (SameValueZero(searchElement, elementK)) {
return true; return true;
} }
......
...@@ -18,7 +18,7 @@ function ArrayCopyWithin(target, start, end) { ...@@ -18,7 +18,7 @@ function ArrayCopyWithin(target, start, end) {
CHECK_OBJECT_COERCIBLE(this, "Array.prototype.copyWithin"); CHECK_OBJECT_COERCIBLE(this, "Array.prototype.copyWithin");
var array = TO_OBJECT_INLINE(this); var array = TO_OBJECT_INLINE(this);
var length = $toLength(array.length); var length = ToLength(array.length);
target = TO_INTEGER(target); target = TO_INTEGER(target);
var to; var to;
...@@ -70,8 +70,8 @@ function ArrayCopyWithin(target, start, end) { ...@@ -70,8 +70,8 @@ function ArrayCopyWithin(target, start, end) {
function ArrayFind(predicate /* thisArg */) { // length == 1 function ArrayFind(predicate /* thisArg */) { // length == 1
CHECK_OBJECT_COERCIBLE(this, "Array.prototype.find"); CHECK_OBJECT_COERCIBLE(this, "Array.prototype.find");
var array = $toObject(this); var array = ToObject(this);
var length = $toInteger(array.length); var length = ToInteger(array.length);
if (!IS_SPEC_FUNCTION(predicate)) { if (!IS_SPEC_FUNCTION(predicate)) {
throw MakeTypeError(kCalledNonCallable, predicate); throw MakeTypeError(kCalledNonCallable, predicate);
...@@ -92,7 +92,7 @@ function ArrayFind(predicate /* thisArg */) { // length == 1 ...@@ -92,7 +92,7 @@ function ArrayFind(predicate /* thisArg */) { // length == 1
for (var i = 0; i < length; i++) { for (var i = 0; i < length; i++) {
if (i in array) { if (i in array) {
var element = array[i]; var element = array[i];
var newThisArg = needs_wrapper ? $toObject(thisArg) : thisArg; var newThisArg = needs_wrapper ? ToObject(thisArg) : thisArg;
if (%_CallFunction(newThisArg, element, i, array, predicate)) { if (%_CallFunction(newThisArg, element, i, array, predicate)) {
return element; return element;
} }
...@@ -107,8 +107,8 @@ function ArrayFind(predicate /* thisArg */) { // length == 1 ...@@ -107,8 +107,8 @@ function ArrayFind(predicate /* thisArg */) { // length == 1
function ArrayFindIndex(predicate /* thisArg */) { // length == 1 function ArrayFindIndex(predicate /* thisArg */) { // length == 1
CHECK_OBJECT_COERCIBLE(this, "Array.prototype.findIndex"); CHECK_OBJECT_COERCIBLE(this, "Array.prototype.findIndex");
var array = $toObject(this); var array = ToObject(this);
var length = $toInteger(array.length); var length = ToInteger(array.length);
if (!IS_SPEC_FUNCTION(predicate)) { if (!IS_SPEC_FUNCTION(predicate)) {
throw MakeTypeError(kCalledNonCallable, predicate); throw MakeTypeError(kCalledNonCallable, predicate);
...@@ -129,7 +129,7 @@ function ArrayFindIndex(predicate /* thisArg */) { // length == 1 ...@@ -129,7 +129,7 @@ function ArrayFindIndex(predicate /* thisArg */) { // length == 1
for (var i = 0; i < length; i++) { for (var i = 0; i < length; i++) {
if (i in array) { if (i in array) {
var element = array[i]; var element = array[i];
var newThisArg = needs_wrapper ? $toObject(thisArg) : thisArg; var newThisArg = needs_wrapper ? ToObject(thisArg) : thisArg;
if (%_CallFunction(newThisArg, element, i, array, predicate)) { if (%_CallFunction(newThisArg, element, i, array, predicate)) {
return i; return i;
} }
...@@ -144,7 +144,7 @@ function ArrayFindIndex(predicate /* thisArg */) { // length == 1 ...@@ -144,7 +144,7 @@ function ArrayFindIndex(predicate /* thisArg */) { // length == 1
function ArrayFill(value /* [, start [, end ] ] */) { // length == 1 function ArrayFill(value /* [, start [, end ] ] */) { // length == 1
CHECK_OBJECT_COERCIBLE(this, "Array.prototype.fill"); CHECK_OBJECT_COERCIBLE(this, "Array.prototype.fill");
var array = $toObject(this); var array = ToObject(this);
var length = TO_UINT32(array.length); var length = TO_UINT32(array.length);
var i = 0; var i = 0;
...@@ -184,7 +184,7 @@ function ArrayFill(value /* [, start [, end ] ] */) { // length == 1 ...@@ -184,7 +184,7 @@ function ArrayFill(value /* [, start [, end ] ] */) { // length == 1
// ES6, draft 10-14-14, section 22.1.2.1 // ES6, draft 10-14-14, section 22.1.2.1
function ArrayFrom(arrayLike, mapfn, receiver) { function ArrayFrom(arrayLike, mapfn, receiver) {
var items = $toObject(arrayLike); var items = ToObject(arrayLike);
var mapping = !IS_UNDEFINED(mapfn); var mapping = !IS_UNDEFINED(mapfn);
if (mapping) { if (mapping) {
...@@ -232,8 +232,8 @@ function ArrayFrom(arrayLike, mapfn, receiver) { ...@@ -232,8 +232,8 @@ function ArrayFrom(arrayLike, mapfn, receiver) {
%AddElement(result, k++, mappedValue, NONE); %AddElement(result, k++, mappedValue, NONE);
} }
} else { } else {
var len = $toLength(items.length); var len = ToLength(items.length);
result = %IsConstructor(this) ? new this(len) : new GlobalArray(len); result = %IsConstructor(this) ? new this(len) : new $Array(len);
for (k = 0; k < len; ++k) { for (k = 0; k < len; ++k) {
nextValue = items[k]; nextValue = items[k];
......
...@@ -16,7 +16,7 @@ var GlobalRegExp = global.RegExp; ...@@ -16,7 +16,7 @@ var GlobalRegExp = global.RegExp;
// + https://bugs.ecmascript.org/show_bug.cgi?id=3423 // + https://bugs.ecmascript.org/show_bug.cgi?id=3423
function RegExpGetFlags() { function RegExpGetFlags() {
if (!IS_SPEC_OBJECT(this)) { if (!IS_SPEC_OBJECT(this)) {
throw MakeTypeError(kFlagsGetterNonObject, $toString(this)); throw MakeTypeError(kFlagsGetterNonObject, %ToString(this));
} }
var result = ''; var result = '';
if (this.global) result += 'g'; if (this.global) result += 'g';
......
...@@ -55,7 +55,7 @@ function NAMEForEach(f /* thisArg */) { // length == 1 ...@@ -55,7 +55,7 @@ function NAMEForEach(f /* thisArg */) { // length == 1
var element = this[i]; var element = this[i];
// Prepare break slots for debugger step in. // Prepare break slots for debugger step in.
if (stepping) %DebugPrepareStepInIfStepping(f); if (stepping) %DebugPrepareStepInIfStepping(f);
var new_receiver = needs_wrapper ? $toObject(receiver) : receiver; var new_receiver = needs_wrapper ? ToObject(receiver) : receiver;
%_CallFunction(new_receiver, TO_OBJECT_INLINE(element), i, this, f); %_CallFunction(new_receiver, TO_OBJECT_INLINE(element), i, this, f);
} }
} }
......
...@@ -287,7 +287,7 @@ function supportedLocalesOf(service, locales, options) { ...@@ -287,7 +287,7 @@ function supportedLocalesOf(service, locales, options) {
if (options === undefined) { if (options === undefined) {
options = {}; options = {};
} else { } else {
options = $toObject(options); options = ToObject(options);
} }
var matcher = options.localeMatcher; var matcher = options.localeMatcher;
...@@ -743,7 +743,7 @@ function initializeLocaleList(locales) { ...@@ -743,7 +743,7 @@ function initializeLocaleList(locales) {
return freezeArray(seen); return freezeArray(seen);
} }
var o = $toObject(locales); var o = ToObject(locales);
// Converts it to UInt32 (>>> is shr on 32bit integers). // Converts it to UInt32 (>>> is shr on 32bit integers).
var len = o.length >>> 0; var len = o.length >>> 0;
...@@ -955,7 +955,7 @@ function initializeCollator(collator, locales, options) { ...@@ -955,7 +955,7 @@ function initializeCollator(collator, locales, options) {
return new Intl.Collator(locales, options); return new Intl.Collator(locales, options);
} }
return initializeCollator($toObject(this), locales, options); return initializeCollator(ToObject(this), locales, options);
}, },
DONT_ENUM DONT_ENUM
); );
...@@ -1181,7 +1181,7 @@ function initializeNumberFormat(numberFormat, locales, options) { ...@@ -1181,7 +1181,7 @@ function initializeNumberFormat(numberFormat, locales, options) {
return new Intl.NumberFormat(locales, options); return new Intl.NumberFormat(locales, options);
} }
return initializeNumberFormat($toObject(this), locales, options); return initializeNumberFormat(ToObject(this), locales, options);
}, },
DONT_ENUM DONT_ENUM
); );
...@@ -1266,7 +1266,7 @@ $setFunctionName(Intl.NumberFormat.supportedLocalesOf, 'supportedLocalesOf'); ...@@ -1266,7 +1266,7 @@ $setFunctionName(Intl.NumberFormat.supportedLocalesOf, 'supportedLocalesOf');
*/ */
function formatNumber(formatter, value) { function formatNumber(formatter, value) {
// Spec treats -0 and +0 as 0. // Spec treats -0 and +0 as 0.
var number = $toNumber(value) + 0; var number = GlobalNumber(value) + 0;
return %InternalNumberFormat(%GetImplFromInitializedIntlObject(formatter), return %InternalNumberFormat(%GetImplFromInitializedIntlObject(formatter),
number); number);
...@@ -1573,7 +1573,7 @@ function initializeDateTimeFormat(dateFormat, locales, options) { ...@@ -1573,7 +1573,7 @@ function initializeDateTimeFormat(dateFormat, locales, options) {
return new Intl.DateTimeFormat(locales, options); return new Intl.DateTimeFormat(locales, options);
} }
return initializeDateTimeFormat($toObject(this), locales, options); return initializeDateTimeFormat(ToObject(this), locales, options);
}, },
DONT_ENUM DONT_ENUM
); );
...@@ -1661,7 +1661,7 @@ function formatDate(formatter, dateValue) { ...@@ -1661,7 +1661,7 @@ function formatDate(formatter, dateValue) {
if (dateValue === undefined) { if (dateValue === undefined) {
dateMs = GlobalDate.now(); dateMs = GlobalDate.now();
} else { } else {
dateMs = $toNumber(dateValue); dateMs = GlobalNumber(dateValue);
} }
if (!$isFinite(dateMs)) throw MakeRangeError(kDateRange); if (!$isFinite(dateMs)) throw MakeRangeError(kDateRange);
...@@ -1774,7 +1774,7 @@ function initializeBreakIterator(iterator, locales, options) { ...@@ -1774,7 +1774,7 @@ function initializeBreakIterator(iterator, locales, options) {
return new Intl.v8BreakIterator(locales, options); return new Intl.v8BreakIterator(locales, options);
} }
return initializeBreakIterator($toObject(this), locales, options); return initializeBreakIterator(ToObject(this), locales, options);
}, },
DONT_ENUM DONT_ENUM
); );
......
...@@ -154,10 +154,10 @@ function JSONSerialize(key, holder, replacer, stack, indent, gap) { ...@@ -154,10 +154,10 @@ function JSONSerialize(key, holder, replacer, stack, indent, gap) {
if (IS_ARRAY(value)) { if (IS_ARRAY(value)) {
return SerializeArray(value, replacer, stack, indent, gap); return SerializeArray(value, replacer, stack, indent, gap);
} else if (IS_NUMBER_WRAPPER(value)) { } else if (IS_NUMBER_WRAPPER(value)) {
value = $toNumber(value); value = ToNumber(value);
return JSON_NUMBER_TO_STRING(value); return JSON_NUMBER_TO_STRING(value);
} else if (IS_STRING_WRAPPER(value)) { } else if (IS_STRING_WRAPPER(value)) {
return %QuoteJSONString($toString(value)); return %QuoteJSONString(ToString(value));
} else if (IS_BOOLEAN_WRAPPER(value)) { } else if (IS_BOOLEAN_WRAPPER(value)) {
return %_ValueOf(value) ? "true" : "false"; return %_ValueOf(value) ? "true" : "false";
} else { } else {
...@@ -176,14 +176,14 @@ function JSONStringify(value, replacer, space) { ...@@ -176,14 +176,14 @@ function JSONStringify(value, replacer, space) {
if (IS_OBJECT(space)) { if (IS_OBJECT(space)) {
// Unwrap 'space' if it is wrapped // Unwrap 'space' if it is wrapped
if (IS_NUMBER_WRAPPER(space)) { if (IS_NUMBER_WRAPPER(space)) {
space = $toNumber(space); space = ToNumber(space);
} else if (IS_STRING_WRAPPER(space)) { } else if (IS_STRING_WRAPPER(space)) {
space = $toString(space); space = ToString(space);
} }
} }
var gap; var gap;
if (IS_NUMBER(space)) { if (IS_NUMBER(space)) {
space = $max(0, $min($toInteger(space), 10)); space = $max(0, $min(ToInteger(space), 10));
gap = %_SubString(" ", 0, space); gap = %_SubString(" ", 0, space);
} else if (IS_STRING(space)) { } else if (IS_STRING(space)) {
if (space.length > 10) { if (space.length > 10) {
...@@ -203,9 +203,9 @@ function JSONStringify(value, replacer, space) { ...@@ -203,9 +203,9 @@ function JSONStringify(value, replacer, space) {
for (var i = 0; i < length; i++) { for (var i = 0; i < length; i++) {
var item = replacer[i]; var item = replacer[i];
if (IS_STRING_WRAPPER(item)) { if (IS_STRING_WRAPPER(item)) {
item = $toString(item); item = ToString(item);
} else { } else {
if (IS_NUMBER_WRAPPER(item)) item = $toNumber(item); if (IS_NUMBER_WRAPPER(item)) item = ToNumber(item);
if (IS_NUMBER(item)) item = %_NumberToString(item); if (IS_NUMBER(item)) item = %_NumberToString(item);
} }
if (IS_STRING(item) && seen_properties[item] != seen_sentinel) { if (IS_STRING(item) && seen_properties[item] != seen_sentinel) {
......
...@@ -143,14 +143,14 @@ define kBoundArgumentsStartIndex = 2; ...@@ -143,14 +143,14 @@ define kBoundArgumentsStartIndex = 2;
# Inline macros. Use %IS_VAR to make sure arg is evaluated only once. # Inline macros. Use %IS_VAR to make sure arg is evaluated only once.
macro NUMBER_IS_NAN(arg) = (!%_IsSmi(%IS_VAR(arg)) && !(arg == arg)); macro NUMBER_IS_NAN(arg) = (!%_IsSmi(%IS_VAR(arg)) && !(arg == arg));
macro NUMBER_IS_FINITE(arg) = (%_IsSmi(%IS_VAR(arg)) || ((arg == arg) && (arg != 1/0) && (arg != -1/0))); macro NUMBER_IS_FINITE(arg) = (%_IsSmi(%IS_VAR(arg)) || ((arg == arg) && (arg != 1/0) && (arg != -1/0)));
macro TO_INTEGER(arg) = (%_IsSmi(%IS_VAR(arg)) ? arg : %NumberToInteger($toNumber(arg))); macro TO_INTEGER(arg) = (%_IsSmi(%IS_VAR(arg)) ? arg : %NumberToInteger(ToNumber(arg)));
macro TO_INTEGER_FOR_SIDE_EFFECT(arg) = (%_IsSmi(%IS_VAR(arg)) ? arg : $toNumber(arg)); macro TO_INTEGER_FOR_SIDE_EFFECT(arg) = (%_IsSmi(%IS_VAR(arg)) ? arg : ToNumber(arg));
macro TO_INTEGER_MAP_MINUS_ZERO(arg) = (%_IsSmi(%IS_VAR(arg)) ? arg : %NumberToIntegerMapMinusZero($toNumber(arg))); macro TO_INTEGER_MAP_MINUS_ZERO(arg) = (%_IsSmi(%IS_VAR(arg)) ? arg : %NumberToIntegerMapMinusZero(ToNumber(arg)));
macro TO_INT32(arg) = (%_IsSmi(%IS_VAR(arg)) ? arg : (arg >> 0)); macro TO_INT32(arg) = (%_IsSmi(%IS_VAR(arg)) ? arg : (arg >> 0));
macro TO_UINT32(arg) = (arg >>> 0); macro TO_UINT32(arg) = (arg >>> 0);
macro TO_STRING_INLINE(arg) = (IS_STRING(%IS_VAR(arg)) ? arg : $nonStringToString(arg)); macro TO_STRING_INLINE(arg) = (IS_STRING(%IS_VAR(arg)) ? arg : NonStringToString(arg));
macro TO_NUMBER_INLINE(arg) = (IS_NUMBER(%IS_VAR(arg)) ? arg : $nonNumberToNumber(arg)); macro TO_NUMBER_INLINE(arg) = (IS_NUMBER(%IS_VAR(arg)) ? arg : NonNumberToNumber(arg));
macro TO_OBJECT_INLINE(arg) = (IS_SPEC_OBJECT(%IS_VAR(arg)) ? arg : $toObject(arg)); macro TO_OBJECT_INLINE(arg) = (IS_SPEC_OBJECT(%IS_VAR(arg)) ? arg : ToObject(arg));
macro JSON_NUMBER_TO_STRING(arg) = ((%_IsSmi(%IS_VAR(arg)) || arg - arg == 0) ? %_NumberToString(arg) : "null"); macro JSON_NUMBER_TO_STRING(arg) = ((%_IsSmi(%IS_VAR(arg)) || arg - arg == 0) ? %_NumberToString(arg) : "null");
macro HAS_OWN_PROPERTY(arg, index) = (%_CallFunction(arg, index, $objectHasOwnProperty)); macro HAS_OWN_PROPERTY(arg, index) = (%_CallFunction(arg, index, $objectHasOwnProperty));
macro SHOULD_CREATE_WRAPPER(functionName, receiver) = (!IS_SPEC_OBJECT(receiver) && %IsSloppyModeFunction(functionName)); macro SHOULD_CREATE_WRAPPER(functionName, receiver) = (!IS_SPEC_OBJECT(receiver) && %IsSloppyModeFunction(functionName));
......
...@@ -88,7 +88,7 @@ function MathMax(arg1, arg2) { // length == 2 ...@@ -88,7 +88,7 @@ function MathMax(arg1, arg2) { // length == 2
var r = -INFINITY; var r = -INFINITY;
for (var i = 0; i < length; i++) { for (var i = 0; i < length; i++) {
var n = %_Arguments(i); var n = %_Arguments(i);
n = TO_NUMBER_INLINE(n); if (!IS_NUMBER(n)) n = NonNumberToNumber(n);
// Make sure +0 is considered greater than -0. // Make sure +0 is considered greater than -0.
if (NUMBER_IS_NAN(n) || n > r || (r === 0 && n === 0 && %_IsMinusZero(r))) { if (NUMBER_IS_NAN(n) || n > r || (r === 0 && n === 0 && %_IsMinusZero(r))) {
r = n; r = n;
...@@ -115,7 +115,7 @@ function MathMin(arg1, arg2) { // length == 2 ...@@ -115,7 +115,7 @@ function MathMin(arg1, arg2) { // length == 2
var r = INFINITY; var r = INFINITY;
for (var i = 0; i < length; i++) { for (var i = 0; i < length; i++) {
var n = %_Arguments(i); var n = %_Arguments(i);
n = TO_NUMBER_INLINE(n); if (!IS_NUMBER(n)) n = NonNumberToNumber(n);
// Make sure -0 is considered less than +0. // Make sure -0 is considered less than +0.
if (NUMBER_IS_NAN(n) || n < r || (r === 0 && n === 0 && %_IsMinusZero(n))) { if (NUMBER_IS_NAN(n) || n < r || (r === 0 && n === 0 && %_IsMinusZero(n))) {
r = n; r = n;
...@@ -175,7 +175,7 @@ function MathTrunc(x) { ...@@ -175,7 +175,7 @@ function MathTrunc(x) {
// ES6 draft 09-27-13, section 20.2.2.33. // ES6 draft 09-27-13, section 20.2.2.33.
function MathTanh(x) { function MathTanh(x) {
x = TO_NUMBER_INLINE(x); if (!IS_NUMBER(x)) x = NonNumberToNumber(x);
// Idempotent for +/-0. // Idempotent for +/-0.
if (x === 0) return x; if (x === 0) return x;
// Returns +/-1 for +/-Infinity. // Returns +/-1 for +/-Infinity.
...@@ -187,7 +187,7 @@ function MathTanh(x) { ...@@ -187,7 +187,7 @@ function MathTanh(x) {
// ES6 draft 09-27-13, section 20.2.2.5. // ES6 draft 09-27-13, section 20.2.2.5.
function MathAsinh(x) { function MathAsinh(x) {
x = TO_NUMBER_INLINE(x); if (!IS_NUMBER(x)) x = NonNumberToNumber(x);
// Idempotent for NaN, +/-0 and +/-Infinity. // Idempotent for NaN, +/-0 and +/-Infinity.
if (x === 0 || !NUMBER_IS_FINITE(x)) return x; if (x === 0 || !NUMBER_IS_FINITE(x)) return x;
if (x > 0) return MathLog(x + %_MathSqrt(x * x + 1)); if (x > 0) return MathLog(x + %_MathSqrt(x * x + 1));
...@@ -197,7 +197,7 @@ function MathAsinh(x) { ...@@ -197,7 +197,7 @@ function MathAsinh(x) {
// ES6 draft 09-27-13, section 20.2.2.3. // ES6 draft 09-27-13, section 20.2.2.3.
function MathAcosh(x) { function MathAcosh(x) {
x = TO_NUMBER_INLINE(x); if (!IS_NUMBER(x)) x = NonNumberToNumber(x);
if (x < 1) return NAN; if (x < 1) return NAN;
// Idempotent for NaN and +Infinity. // Idempotent for NaN and +Infinity.
if (!NUMBER_IS_FINITE(x)) return x; if (!NUMBER_IS_FINITE(x)) return x;
...@@ -206,7 +206,7 @@ function MathAcosh(x) { ...@@ -206,7 +206,7 @@ function MathAcosh(x) {
// ES6 draft 09-27-13, section 20.2.2.7. // ES6 draft 09-27-13, section 20.2.2.7.
function MathAtanh(x) { function MathAtanh(x) {
x = TO_NUMBER_INLINE(x); if (!IS_NUMBER(x)) x = NonNumberToNumber(x);
// Idempotent for +/-0. // Idempotent for +/-0.
if (x === 0) return x; if (x === 0) return x;
// Returns NaN for NaN and +/- Infinity. // Returns NaN for NaN and +/- Infinity.
...@@ -224,7 +224,7 @@ function MathHypot(x, y) { // Function length is 2. ...@@ -224,7 +224,7 @@ function MathHypot(x, y) { // Function length is 2.
var max = 0; var max = 0;
for (var i = 0; i < length; i++) { for (var i = 0; i < length; i++) {
var n = %_Arguments(i); var n = %_Arguments(i);
n = TO_NUMBER_INLINE(n); if (!IS_NUMBER(n)) n = NonNumberToNumber(n);
if (n === INFINITY || n === -INFINITY) return INFINITY; if (n === INFINITY || n === -INFINITY) return INFINITY;
n = MathAbs(n); n = MathAbs(n);
if (n > max) max = n; if (n > max) max = n;
...@@ -261,7 +261,7 @@ function MathClz32JS(x) { ...@@ -261,7 +261,7 @@ function MathClz32JS(x) {
// Using initial approximation adapted from Kahan's cbrt and 4 iterations // Using initial approximation adapted from Kahan's cbrt and 4 iterations
// of Newton's method. // of Newton's method.
function MathCbrt(x) { function MathCbrt(x) {
x = TO_NUMBER_INLINE(x); if (!IS_NUMBER(x)) x = NonNumberToNumber(x);
if (x == 0 || !NUMBER_IS_FINITE(x)) return x; if (x == 0 || !NUMBER_IS_FINITE(x)) return x;
return x >= 0 ? CubeRoot(x) : -CubeRoot(-x); return x >= 0 ? CubeRoot(x) : -CubeRoot(-x);
} }
......
...@@ -269,7 +269,7 @@ function ToStringCheckErrorObject(obj) { ...@@ -269,7 +269,7 @@ function ToStringCheckErrorObject(obj) {
if (CanBeSafelyTreatedAsAnErrorObject(obj)) { if (CanBeSafelyTreatedAsAnErrorObject(obj)) {
return %_CallFunction(obj, ErrorToString); return %_CallFunction(obj, ErrorToString);
} else { } else {
return $toString(obj); return ToString(obj);
} }
} }
...@@ -1089,7 +1089,7 @@ function DefineError(f) { ...@@ -1089,7 +1089,7 @@ function DefineError(f) {
// object. This avoids going through getters and setters defined // object. This avoids going through getters and setters defined
// on prototype objects. // on prototype objects.
if (!IS_UNDEFINED(m)) { if (!IS_UNDEFINED(m)) {
%AddNamedProperty(this, 'message', $toString(m), DONT_ENUM); %AddNamedProperty(this, 'message', ToString(m), DONT_ENUM);
} }
} else { } else {
return new f(m); return new f(m);
......
...@@ -823,7 +823,7 @@ ObjectMirror.prototype.internalProperties = function() { ...@@ -823,7 +823,7 @@ ObjectMirror.prototype.internalProperties = function() {
ObjectMirror.prototype.property = function(name) { ObjectMirror.prototype.property = function(name) {
var details = %DebugGetPropertyDetails(this.value_, builtins.$toName(name)); var details = %DebugGetPropertyDetails(this.value_, %ToName(name));
if (details) { if (details) {
return new PropertyMirror(this, name, details); return new PropertyMirror(this, name, details);
} }
...@@ -1186,7 +1186,7 @@ ArrayMirror.prototype.indexedPropertiesFromRange = function(opt_from_index, ...@@ -1186,7 +1186,7 @@ ArrayMirror.prototype.indexedPropertiesFromRange = function(opt_from_index,
if (from_index > to_index) return new Array(); if (from_index > to_index) return new Array();
var values = new Array(to_index - from_index + 1); var values = new Array(to_index - from_index + 1);
for (var i = from_index; i <= to_index; i++) { for (var i = from_index; i <= to_index; i++) {
var details = %DebugGetPropertyDetails(this.value_, builtins.$toString(i)); var details = %DebugGetPropertyDetails(this.value_, %ToString(i));
var value; var value;
if (details) { if (details) {
value = new PropertyMirror(this, i, details); value = new PropertyMirror(this, i, details);
......
...@@ -317,7 +317,7 @@ function ConvertAcceptListToTypeMap(arg) { ...@@ -317,7 +317,7 @@ function ConvertAcceptListToTypeMap(arg) {
if (!IS_SPEC_OBJECT(arg)) throw MakeTypeError(kObserveInvalidAccept); if (!IS_SPEC_OBJECT(arg)) throw MakeTypeError(kObserveInvalidAccept);
var len = $toInteger(arg.length); var len = ToInteger(arg.length);
if (len < 0) len = 0; if (len < 0) len = 0;
return TypeMapCreateFromList(arg, len); return TypeMapCreateFromList(arg, len);
......
...@@ -2245,8 +2245,8 @@ class JSObject: public JSReceiver { ...@@ -2245,8 +2245,8 @@ class JSObject: public JSReceiver {
// permissible values (see the DCHECK in heap.cc). // permissible values (see the DCHECK in heap.cc).
static const int kInitialMaxFastElementArray = 100000; static const int kInitialMaxFastElementArray = 100000;
// This constant applies only to the initial map of "global.Object" and // This constant applies only to the initial map of "$Object" aka
// not to arbitrary other JSObject maps. // "global.Object" and not to arbitrary other JSObject maps.
static const int kInitialGlobalObjectUnusedPropertiesCount = 4; static const int kInitialGlobalObjectUnusedPropertiesCount = 4;
static const int kMaxInstanceSize = 255 * kPointerSize; static const int kMaxInstanceSize = 255 * kPointerSize;
......
...@@ -55,8 +55,8 @@ function DoConstructRegExp(object, pattern, flags) { ...@@ -55,8 +55,8 @@ function DoConstructRegExp(object, pattern, flags) {
pattern = pattern.source; pattern = pattern.source;
} }
pattern = IS_UNDEFINED(pattern) ? '' : $toString(pattern); pattern = IS_UNDEFINED(pattern) ? '' : ToString(pattern);
flags = IS_UNDEFINED(flags) ? '' : $toString(flags); flags = IS_UNDEFINED(flags) ? '' : ToString(flags);
%RegExpInitializeAndCompile(object, pattern, flags); %RegExpInitializeAndCompile(object, pattern, flags);
} }
...@@ -381,7 +381,7 @@ var RegExpGetInput = function() { ...@@ -381,7 +381,7 @@ var RegExpGetInput = function() {
return IS_UNDEFINED(regExpInput) ? "" : regExpInput; return IS_UNDEFINED(regExpInput) ? "" : regExpInput;
}; };
var RegExpSetInput = function(string) { var RegExpSetInput = function(string) {
LAST_INPUT($regexpLastMatchInfo) = $toString(string); LAST_INPUT($regexpLastMatchInfo) = ToString(string);
}; };
%OptimizeObjectForAddingMultipleProperties(GlobalRegExp, 22); %OptimizeObjectForAddingMultipleProperties(GlobalRegExp, 22);
......
This diff is collapsed.
...@@ -39,7 +39,7 @@ function StringIteratorIterator() { ...@@ -39,7 +39,7 @@ function StringIteratorIterator() {
// 21.1.5.2.1 %StringIteratorPrototype%.next( ) // 21.1.5.2.1 %StringIteratorPrototype%.next( )
function StringIteratorNext() { function StringIteratorNext() {
var iterator = $toObject(this); var iterator = ToObject(this);
if (!HAS_DEFINED_PRIVATE(iterator, stringIteratorNextIndexSymbol)) { if (!HAS_DEFINED_PRIVATE(iterator, stringIteratorNextIndexSymbol)) {
throw MakeTypeError(kIncompatibleMethodReceiver, throw MakeTypeError(kIncompatibleMethodReceiver,
......
...@@ -113,7 +113,7 @@ function StringLastIndexOfJS(pat /* position */) { // length == 1 ...@@ -113,7 +113,7 @@ function StringLastIndexOfJS(pat /* position */) { // length == 1
var patLength = pat.length; var patLength = pat.length;
var index = subLength - patLength; var index = subLength - patLength;
if (%_ArgumentsLength() > 1) { if (%_ArgumentsLength() > 1) {
var position = $toNumber(%_Arguments(1)); var position = ToNumber(%_Arguments(1));
if (!NUMBER_IS_NAN(position)) { if (!NUMBER_IS_NAN(position)) {
position = TO_INTEGER(position); position = TO_INTEGER(position);
if (position < 0) { if (position < 0) {
...@@ -803,7 +803,7 @@ function StringTrimRight() { ...@@ -803,7 +803,7 @@ function StringTrimRight() {
function StringFromCharCode(code) { function StringFromCharCode(code) {
var n = %_ArgumentsLength(); var n = %_ArgumentsLength();
if (n == 1) { if (n == 1) {
if (!%_IsSmi(code)) code = $toNumber(code); if (!%_IsSmi(code)) code = ToNumber(code);
return %_StringCharFromCode(code & 0xffff); return %_StringCharFromCode(code & 0xffff);
} }
...@@ -811,7 +811,7 @@ function StringFromCharCode(code) { ...@@ -811,7 +811,7 @@ function StringFromCharCode(code) {
var i; var i;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
var code = %_Arguments(i); var code = %_Arguments(i);
if (!%_IsSmi(code)) code = $toNumber(code) & 0xffff; if (!%_IsSmi(code)) code = ToNumber(code) & 0xffff;
if (code < 0) code = code & 0xffff; if (code < 0) code = code & 0xffff;
if (code > 0xff) break; if (code > 0xff) break;
%_OneByteSeqStringSetChar(i, code, one_byte); %_OneByteSeqStringSetChar(i, code, one_byte);
...@@ -822,7 +822,7 @@ function StringFromCharCode(code) { ...@@ -822,7 +822,7 @@ function StringFromCharCode(code) {
var two_byte = %NewString(n - i, NEW_TWO_BYTE_STRING); var two_byte = %NewString(n - i, NEW_TWO_BYTE_STRING);
for (var j = 0; i < n; i++, j++) { for (var j = 0; i < n; i++, j++) {
var code = %_Arguments(i); var code = %_Arguments(i);
if (!%_IsSmi(code)) code = $toNumber(code) & 0xffff; if (!%_IsSmi(code)) code = ToNumber(code) & 0xffff;
%_TwoByteSeqStringSetChar(j, code, two_byte); %_TwoByteSeqStringSetChar(j, code, two_byte);
} }
return one_byte + two_byte; return one_byte + two_byte;
...@@ -930,7 +930,7 @@ function StringRepeat(count) { ...@@ -930,7 +930,7 @@ function StringRepeat(count) {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.repeat"); CHECK_OBJECT_COERCIBLE(this, "String.prototype.repeat");
var s = TO_STRING_INLINE(this); var s = TO_STRING_INLINE(this);
var n = $toInteger(count); var n = ToInteger(count);
// The maximum string length is stored in a smi, so a longer repeat // The maximum string length is stored in a smi, so a longer repeat
// must result in a range error. // must result in a range error.
if (n < 0 || n > %_MaxSmi()) throw MakeRangeError(kInvalidCountValue); if (n < 0 || n > %_MaxSmi()) throw MakeRangeError(kInvalidCountValue);
...@@ -959,7 +959,7 @@ function StringStartsWith(searchString /* position */) { // length == 1 ...@@ -959,7 +959,7 @@ function StringStartsWith(searchString /* position */) { // length == 1
var pos = 0; var pos = 0;
if (%_ArgumentsLength() > 1) { if (%_ArgumentsLength() > 1) {
pos = %_Arguments(1); // position pos = %_Arguments(1); // position
pos = $toInteger(pos); pos = ToInteger(pos);
} }
var s_len = s.length; var s_len = s.length;
...@@ -989,7 +989,7 @@ function StringEndsWith(searchString /* position */) { // length == 1 ...@@ -989,7 +989,7 @@ function StringEndsWith(searchString /* position */) { // length == 1
if (%_ArgumentsLength() > 1) { if (%_ArgumentsLength() > 1) {
var arg = %_Arguments(1); // position var arg = %_Arguments(1); // position
if (!IS_UNDEFINED(arg)) { if (!IS_UNDEFINED(arg)) {
pos = $toInteger(arg); pos = ToInteger(arg);
} }
} }
...@@ -1018,7 +1018,7 @@ function StringIncludes(searchString /* position */) { // length == 1 ...@@ -1018,7 +1018,7 @@ function StringIncludes(searchString /* position */) { // length == 1
var pos = 0; var pos = 0;
if (%_ArgumentsLength() > 1) { if (%_ArgumentsLength() > 1) {
pos = %_Arguments(1); // position pos = %_Arguments(1); // position
pos = $toInteger(pos); pos = ToInteger(pos);
} }
var s_len = s.length; var s_len = s.length;
...@@ -1063,7 +1063,7 @@ function StringFromCodePoint(_) { // length = 1 ...@@ -1063,7 +1063,7 @@ function StringFromCodePoint(_) { // length = 1
for (index = 0; index < length; index++) { for (index = 0; index < length; index++) {
code = %_Arguments(index); code = %_Arguments(index);
if (!%_IsSmi(code)) { if (!%_IsSmi(code)) {
code = $toNumber(code); code = ToNumber(code);
} }
if (code < 0 || code > 0x10FFFF || code !== TO_INTEGER(code)) { if (code < 0 || code > 0x10FFFF || code !== TO_INTEGER(code)) {
throw MakeRangeError(kInvalidCodePoint, code); throw MakeRangeError(kInvalidCodePoint, code);
...@@ -1087,18 +1087,18 @@ function StringFromCodePoint(_) { // length = 1 ...@@ -1087,18 +1087,18 @@ function StringFromCodePoint(_) { // length = 1
function StringRaw(callSite) { function StringRaw(callSite) {
// TODO(caitp): Use rest parameters when implemented // TODO(caitp): Use rest parameters when implemented
var numberOfSubstitutions = %_ArgumentsLength(); var numberOfSubstitutions = %_ArgumentsLength();
var cooked = $toObject(callSite); var cooked = ToObject(callSite);
var raw = $toObject(cooked.raw); var raw = ToObject(cooked.raw);
var literalSegments = $toLength(raw.length); var literalSegments = ToLength(raw.length);
if (literalSegments <= 0) return ""; if (literalSegments <= 0) return "";
var result = $toString(raw[0]); var result = ToString(raw[0]);
for (var i = 1; i < literalSegments; ++i) { for (var i = 1; i < literalSegments; ++i) {
if (i < numberOfSubstitutions) { if (i < numberOfSubstitutions) {
result += $toString(%_Arguments(i)); result += ToString(%_Arguments(i));
} }
result += $toString(raw[i]); result += ToString(raw[i]);
} }
return result; return result;
......
...@@ -26,7 +26,7 @@ var GlobalSymbol = global.Symbol; ...@@ -26,7 +26,7 @@ var GlobalSymbol = global.Symbol;
function SymbolConstructor(x) { function SymbolConstructor(x) {
if (%_IsConstructCall()) throw MakeTypeError(kNotConstructor, "Symbol"); if (%_IsConstructCall()) throw MakeTypeError(kNotConstructor, "Symbol");
// NOTE: Passing in a Symbol value will throw on ToString(). // NOTE: Passing in a Symbol value will throw on ToString().
return %CreateSymbol(IS_UNDEFINED(x) ? x : $toString(x)); return %CreateSymbol(IS_UNDEFINED(x) ? x : ToString(x));
} }
...@@ -69,7 +69,7 @@ function SymbolKeyFor(symbol) { ...@@ -69,7 +69,7 @@ function SymbolKeyFor(symbol) {
// ES6 19.1.2.8 // ES6 19.1.2.8
function ObjectGetOwnPropertySymbols(obj) { function ObjectGetOwnPropertySymbols(obj) {
obj = $toObject(obj); obj = ToObject(obj);
// TODO(arv): Proxies use a shared trap for String and Symbol keys. // TODO(arv): Proxies use a shared trap for String and Symbol keys.
......
...@@ -38,10 +38,10 @@ macro TYPED_ARRAY_CONSTRUCTOR(ARRAY_ID, NAME, ELEMENT_SIZE) ...@@ -38,10 +38,10 @@ macro TYPED_ARRAY_CONSTRUCTOR(ARRAY_ID, NAME, ELEMENT_SIZE)
function NAMEConstructByArrayBuffer(obj, buffer, byteOffset, length) { function NAMEConstructByArrayBuffer(obj, buffer, byteOffset, length) {
if (!IS_UNDEFINED(byteOffset)) { if (!IS_UNDEFINED(byteOffset)) {
byteOffset = byteOffset =
$toPositiveInteger(byteOffset, kInvalidTypedArrayLength); ToPositiveInteger(byteOffset, kInvalidTypedArrayLength);
} }
if (!IS_UNDEFINED(length)) { if (!IS_UNDEFINED(length)) {
length = $toPositiveInteger(length, kInvalidTypedArrayLength); length = ToPositiveInteger(length, kInvalidTypedArrayLength);
} }
var bufferByteLength = %_ArrayBufferGetByteLength(buffer); var bufferByteLength = %_ArrayBufferGetByteLength(buffer);
...@@ -82,7 +82,7 @@ function NAMEConstructByArrayBuffer(obj, buffer, byteOffset, length) { ...@@ -82,7 +82,7 @@ function NAMEConstructByArrayBuffer(obj, buffer, byteOffset, length) {
function NAMEConstructByLength(obj, length) { function NAMEConstructByLength(obj, length) {
var l = IS_UNDEFINED(length) ? var l = IS_UNDEFINED(length) ?
0 : $toPositiveInteger(length, kInvalidTypedArrayLength); 0 : ToPositiveInteger(length, kInvalidTypedArrayLength);
if (l > %_MaxSmi()) { if (l > %_MaxSmi()) {
throw MakeRangeError(kInvalidTypedArrayLength); throw MakeRangeError(kInvalidTypedArrayLength);
} }
...@@ -97,7 +97,7 @@ function NAMEConstructByLength(obj, length) { ...@@ -97,7 +97,7 @@ function NAMEConstructByLength(obj, length) {
function NAMEConstructByArrayLike(obj, arrayLike) { function NAMEConstructByArrayLike(obj, arrayLike) {
var length = arrayLike.length; var length = arrayLike.length;
var l = $toPositiveInteger(length, kInvalidTypedArrayLength); var l = ToPositiveInteger(length, kInvalidTypedArrayLength);
if (l > %_MaxSmi()) { if (l > %_MaxSmi()) {
throw MakeRangeError(kInvalidTypedArrayLength); throw MakeRangeError(kInvalidTypedArrayLength);
...@@ -335,7 +335,7 @@ function DataViewConstructor(buffer, byteOffset, byteLength) { // length = 3 ...@@ -335,7 +335,7 @@ function DataViewConstructor(buffer, byteOffset, byteLength) { // length = 3
if (%_IsConstructCall()) { if (%_IsConstructCall()) {
if (!IS_ARRAYBUFFER(buffer)) throw MakeTypeError(kDataViewNotArrayBuffer); if (!IS_ARRAYBUFFER(buffer)) throw MakeTypeError(kDataViewNotArrayBuffer);
if (!IS_UNDEFINED(byteOffset)) { if (!IS_UNDEFINED(byteOffset)) {
byteOffset = $toPositiveInteger(byteOffset, kInvalidDataViewOffset); byteOffset = ToPositiveInteger(byteOffset, kInvalidDataViewOffset);
} }
if (!IS_UNDEFINED(byteLength)) { if (!IS_UNDEFINED(byteLength)) {
byteLength = TO_INTEGER(byteLength); byteLength = TO_INTEGER(byteLength);
...@@ -392,6 +392,10 @@ macro DATA_VIEW_TYPES(FUNCTION) ...@@ -392,6 +392,10 @@ macro DATA_VIEW_TYPES(FUNCTION)
FUNCTION(Float64) FUNCTION(Float64)
endmacro endmacro
function ToPositiveDataViewOffset(offset) {
return ToPositiveInteger(offset, kInvalidDataViewAccessorOffset);
}
macro DATA_VIEW_GETTER_SETTER(TYPENAME) macro DATA_VIEW_GETTER_SETTER(TYPENAME)
function DataViewGetTYPENAMEJS(offset, little_endian) { function DataViewGetTYPENAMEJS(offset, little_endian) {
...@@ -400,8 +404,9 @@ function DataViewGetTYPENAMEJS(offset, little_endian) { ...@@ -400,8 +404,9 @@ function DataViewGetTYPENAMEJS(offset, little_endian) {
'DataView.getTYPENAME', this); 'DataView.getTYPENAME', this);
} }
if (%_ArgumentsLength() < 1) throw MakeTypeError(kInvalidArgument); if (%_ArgumentsLength() < 1) throw MakeTypeError(kInvalidArgument);
offset = $toPositiveInteger(offset, kInvalidDataViewAccessorOffset); return %DataViewGetTYPENAME(this,
return %DataViewGetTYPENAME(this, offset, !!little_endian); ToPositiveDataViewOffset(offset),
!!little_endian);
} }
function DataViewSetTYPENAMEJS(offset, value, little_endian) { function DataViewSetTYPENAMEJS(offset, value, little_endian) {
...@@ -410,8 +415,10 @@ function DataViewSetTYPENAMEJS(offset, value, little_endian) { ...@@ -410,8 +415,10 @@ function DataViewSetTYPENAMEJS(offset, value, little_endian) {
'DataView.setTYPENAME', this); 'DataView.setTYPENAME', this);
} }
if (%_ArgumentsLength() < 2) throw MakeTypeError(kInvalidArgument); if (%_ArgumentsLength() < 2) throw MakeTypeError(kInvalidArgument);
offset = $toPositiveInteger(offset, kInvalidDataViewAccessorOffset); %DataViewSetTYPENAME(this,
%DataViewSetTYPENAME(this, offset, TO_NUMBER_INLINE(value), !!little_endian); ToPositiveDataViewOffset(offset),
TO_NUMBER_INLINE(value),
!!little_endian);
} }
endmacro endmacro
......
...@@ -262,13 +262,13 @@ function Decode(uri, reserved) { ...@@ -262,13 +262,13 @@ function Decode(uri, reserved) {
// ECMA-262 - B.2.1. // ECMA-262 - B.2.1.
function URIEscapeJS(str) { function URIEscapeJS(str) {
var s = $toString(str); var s = ToString(str);
return %URIEscape(s); return %URIEscape(s);
} }
// ECMA-262 - B.2.2. // ECMA-262 - B.2.2.
function URIUnescapeJS(str) { function URIUnescapeJS(str) {
var s = $toString(str); var s = ToString(str);
return %URIUnescape(s); return %URIUnescape(s);
} }
...@@ -292,14 +292,14 @@ function URIDecode(uri) { ...@@ -292,14 +292,14 @@ function URIDecode(uri) {
return false; return false;
}; };
var string = $toString(uri); var string = ToString(uri);
return Decode(string, reservedPredicate); return Decode(string, reservedPredicate);
} }
// ECMA-262 - 15.1.3.2. // ECMA-262 - 15.1.3.2.
function URIDecodeComponent(component) { function URIDecodeComponent(component) {
var reservedPredicate = function(cc) { return false; }; var reservedPredicate = function(cc) { return false; };
var string = $toString(component); var string = ToString(component);
return Decode(string, reservedPredicate); return Decode(string, reservedPredicate);
} }
...@@ -326,7 +326,7 @@ function URIEncode(uri) { ...@@ -326,7 +326,7 @@ function URIEncode(uri) {
return false; return false;
}; };
var string = $toString(uri); var string = ToString(uri);
return Encode(string, unescapePredicate); return Encode(string, unescapePredicate);
} }
...@@ -347,7 +347,7 @@ function URIEncodeComponent(component) { ...@@ -347,7 +347,7 @@ function URIEncodeComponent(component) {
return false; return false;
}; };
var string = $toString(component); var string = ToString(component);
return Encode(string, unescapePredicate); return Encode(string, unescapePredicate);
} }
......
This diff is collapsed.
...@@ -158,7 +158,7 @@ TEST(RuntimeCallCPP2) { ...@@ -158,7 +158,7 @@ TEST(RuntimeCallCPP2) {
TEST(RuntimeCallJS) { TEST(RuntimeCallJS) {
FLAG_allow_natives_syntax = true; FLAG_allow_natives_syntax = true;
FunctionTester T("(function(a) { return %$toString(a); })"); FunctionTester T("(function(a) { return %ToString(a); })");
T.CheckCall(T.Val("23"), T.Val(23), T.undefined()); T.CheckCall(T.Val("23"), T.Val(23), T.undefined());
T.CheckCall(T.Val("4.2"), T.Val(4.2), T.undefined()); T.CheckCall(T.Val("4.2"), T.Val(4.2), T.undefined());
......
...@@ -32,73 +32,71 @@ ...@@ -32,73 +32,71 @@
var obj1 = {x: 10, y: 11, z: "test"}; var obj1 = {x: 10, y: 11, z: "test"};
var obj2 = {x: 10, y: 11, z: "test"}; var obj2 = {x: 10, y: 11, z: "test"};
var sameValue = natives.$sameValue; assertTrue(natives.SameValue(0, 0));
assertTrue(natives.SameValue(+0, +0));
assertTrue(sameValue(0, 0)); assertTrue(natives.SameValue(-0, -0));
assertTrue(sameValue(+0, +0)); assertTrue(natives.SameValue(1, 1));
assertTrue(sameValue(-0, -0)); assertTrue(natives.SameValue(2, 2));
assertTrue(sameValue(1, 1)); assertTrue(natives.SameValue(-1, -1));
assertTrue(sameValue(2, 2)); assertTrue(natives.SameValue(0.5, 0.5));
assertTrue(sameValue(-1, -1)); assertTrue(natives.SameValue(true, true));
assertTrue(sameValue(0.5, 0.5)); assertTrue(natives.SameValue(false, false));
assertTrue(sameValue(true, true)); assertTrue(natives.SameValue(NaN, NaN));
assertTrue(sameValue(false, false)); assertTrue(natives.SameValue(null, null));
assertTrue(sameValue(NaN, NaN)); assertTrue(natives.SameValue("foo", "foo"));
assertTrue(sameValue(null, null)); assertTrue(natives.SameValue(obj1, obj1));
assertTrue(sameValue("foo", "foo"));
assertTrue(sameValue(obj1, obj1));
// Undefined values. // Undefined values.
assertTrue(sameValue()); assertTrue(natives.SameValue());
assertTrue(sameValue(undefined, undefined)); assertTrue(natives.SameValue(undefined, undefined));
assertFalse(sameValue(0,1)); assertFalse(natives.SameValue(0,1));
assertFalse(sameValue("foo", "bar")); assertFalse(natives.SameValue("foo", "bar"));
assertFalse(sameValue(obj1, obj2)); assertFalse(natives.SameValue(obj1, obj2));
assertFalse(sameValue(true, false)); assertFalse(natives.SameValue(true, false));
assertFalse(sameValue(obj1, true)); assertFalse(natives.SameValue(obj1, true));
assertFalse(sameValue(obj1, "foo")); assertFalse(natives.SameValue(obj1, "foo"));
assertFalse(sameValue(obj1, 1)); assertFalse(natives.SameValue(obj1, 1));
assertFalse(sameValue(obj1, undefined)); assertFalse(natives.SameValue(obj1, undefined));
assertFalse(sameValue(obj1, NaN)); assertFalse(natives.SameValue(obj1, NaN));
assertFalse(sameValue(undefined, true)); assertFalse(natives.SameValue(undefined, true));
assertFalse(sameValue(undefined, "foo")); assertFalse(natives.SameValue(undefined, "foo"));
assertFalse(sameValue(undefined, 1)); assertFalse(natives.SameValue(undefined, 1));
assertFalse(sameValue(undefined, obj1)); assertFalse(natives.SameValue(undefined, obj1));
assertFalse(sameValue(undefined, NaN)); assertFalse(natives.SameValue(undefined, NaN));
assertFalse(sameValue(NaN, true)); assertFalse(natives.SameValue(NaN, true));
assertFalse(sameValue(NaN, "foo")); assertFalse(natives.SameValue(NaN, "foo"));
assertFalse(sameValue(NaN, 1)); assertFalse(natives.SameValue(NaN, 1));
assertFalse(sameValue(NaN, obj1)); assertFalse(natives.SameValue(NaN, obj1));
assertFalse(sameValue(NaN, undefined)); assertFalse(natives.SameValue(NaN, undefined));
assertFalse(sameValue("foo", true)); assertFalse(natives.SameValue("foo", true));
assertFalse(sameValue("foo", 1)); assertFalse(natives.SameValue("foo", 1));
assertFalse(sameValue("foo", obj1)); assertFalse(natives.SameValue("foo", obj1));
assertFalse(sameValue("foo", undefined)); assertFalse(natives.SameValue("foo", undefined));
assertFalse(sameValue("foo", NaN)); assertFalse(natives.SameValue("foo", NaN));
assertFalse(sameValue(true, 1)); assertFalse(natives.SameValue(true, 1));
assertFalse(sameValue(true, obj1)); assertFalse(natives.SameValue(true, obj1));
assertFalse(sameValue(true, undefined)); assertFalse(natives.SameValue(true, undefined));
assertFalse(sameValue(true, NaN)); assertFalse(natives.SameValue(true, NaN));
assertFalse(sameValue(true, "foo")); assertFalse(natives.SameValue(true, "foo"));
assertFalse(sameValue(1, true)); assertFalse(natives.SameValue(1, true));
assertFalse(sameValue(1, obj1)); assertFalse(natives.SameValue(1, obj1));
assertFalse(sameValue(1, undefined)); assertFalse(natives.SameValue(1, undefined));
assertFalse(sameValue(1, NaN)); assertFalse(natives.SameValue(1, NaN));
assertFalse(sameValue(1, "foo")); assertFalse(natives.SameValue(1, "foo"));
// Special string cases. // Special string cases.
assertFalse(sameValue("1", 1)); assertFalse(natives.SameValue("1", 1));
assertFalse(sameValue("true", true)); assertFalse(natives.SameValue("true", true));
assertFalse(sameValue("false", false)); assertFalse(natives.SameValue("false", false));
assertFalse(sameValue("undefined", undefined)); assertFalse(natives.SameValue("undefined", undefined));
assertFalse(sameValue("NaN", NaN)); assertFalse(natives.SameValue("NaN", NaN));
// -0 and +0 are should be different // -0 and +0 are should be different
assertFalse(sameValue(+0, -0)); assertFalse(natives.SameValue(+0, -0));
assertFalse(sameValue(-0, +0)); assertFalse(natives.SameValue(-0, +0));
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment