}
+// TODO(verwaest): Remove the attribs argument, since it doesn't make sense for
+// existing properties. Use ForceSet instead to define or redefine properties
+// with specific attributes.
bool v8::Object::Set(v8::Handle<Value> key, v8::Handle<Value> value,
v8::PropertyAttribute attribs) {
i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
i::Handle<i::Object> value_obj = Utils::OpenHandle(*value);
EXCEPTION_PREAMBLE(isolate);
has_pending_exception = i::Runtime::SetObjectProperty(
- isolate,
- self,
- key_obj,
- value_obj,
- static_cast<PropertyAttributes>(attribs),
- i::SLOPPY).is_null();
+ isolate, self, key_obj, value_obj, i::SLOPPY,
+ static_cast<PropertyAttributes>(attribs)).is_null();
EXCEPTION_BAILOUT_CHECK(isolate, false);
return true;
}
i::Handle<i::Object> key_obj = Utils::OpenHandle(*key);
i::Handle<i::Object> value_obj = Utils::OpenHandle(*value);
EXCEPTION_PREAMBLE(isolate);
- has_pending_exception = i::Runtime::ForceSetObjectProperty(
+ has_pending_exception = i::Runtime::DefineObjectProperty(
self,
key_obj,
value_obj,
var Constructor = %GetTemplateField(data, kApiConstructorOffset);
// Note: Do not directly use a function template as a condition, our
// internal ToBoolean doesn't handle that!
- var result = typeof Constructor === 'undefined' ?
- {} : new (Instantiate(Constructor))();
- ConfigureTemplateInstance(result, data);
- result = %ToFastProperties(result);
+ var result;
+ if (typeof Constructor === 'undefined') {
+ result = {};
+ ConfigureTemplateInstance(result, data);
+ } else {
+ // ConfigureTemplateInstance is implicitly called before calling the API
+ // constructor in HandleApiCall.
+ result = new (Instantiate(Constructor))();
+ result = %ToFastProperties(result);
+ }
return result;
default:
throw 'Unknown API tag <' + tag + '>';
var prop_data = properties[i + 2];
var attributes = properties[i + 3];
var value = Instantiate(prop_data, name);
- %SetProperty(obj, name, value, attributes);
+ %AddProperty(obj, name, value, attributes);
} else if (length == 4 || length == 5) {
// TODO(verwaest): The 5th value used to be access_control. Remove once
// the bindings are updated.
var name = properties[i + 1];
- var getter = properties[i + 2];
- var setter = properties[i + 3];
+ var getter = Instantiate(properties[i + 2]);
+ var setter = Instantiate(properties[i + 3]);
var attribute = properties[i + 4];
- %SetAccessorProperty(obj, name, getter, setter, attribute);
+ %DefineAccessorPropertyUnchecked(obj, name, getter, setter, attribute);
} else {
throw "Bad properties array";
}
if (property->emit_store()) {
__ mov(r0, Operand(Smi::FromInt(NONE))); // PropertyAttributes
__ push(r0);
- __ CallRuntime(Runtime::kSetProperty, 4);
+ __ CallRuntime(Runtime::kAddProperty, 4);
} else {
__ Drop(3);
}
EmitAccessor(it->second->setter);
__ mov(r0, Operand(Smi::FromInt(NONE)));
__ push(r0);
- __ CallRuntime(Runtime::kDefineOrRedefineAccessorProperty, 5);
+ __ CallRuntime(Runtime::kDefineAccessorPropertyUnchecked, 5);
}
if (expr->has_function()) {
// Push receiver, key and value for runtime call.
__ Push(r2, r1, r0);
- __ mov(r1, Operand(Smi::FromInt(NONE))); // PropertyAttributes
__ mov(r0, Operand(Smi::FromInt(strict_mode))); // Strict mode.
__ Push(r1, r0);
- __ TailCallRuntime(Runtime::kSetProperty, 5, 1);
+ __ TailCallRuntime(Runtime::kSetProperty, 4, 1);
}
VisitForStackValue(value);
__ Mov(x0, Smi::FromInt(NONE)); // PropertyAttributes
__ Push(x0);
- __ CallRuntime(Runtime::kSetProperty, 4);
+ __ CallRuntime(Runtime::kAddProperty, 4);
} else {
VisitForEffect(key);
VisitForEffect(value);
EmitAccessor(it->second->setter);
__ Mov(x10, Smi::FromInt(NONE));
__ Push(x10);
- __ CallRuntime(Runtime::kDefineOrRedefineAccessorProperty, 5);
+ __ CallRuntime(Runtime::kDefineAccessorPropertyUnchecked, 5);
}
if (expr->has_function()) {
'next', ArrayIteratorNext
));
%FunctionSetName(ArrayIteratorIterator, '[Symbol.iterator]');
- %SetProperty(ArrayIterator.prototype, symbolIterator, ArrayIteratorIterator,
+ %AddProperty(ArrayIterator.prototype, symbolIterator, ArrayIteratorIterator,
DONT_ENUM);
}
SetUpArrayIterator();
'keys', ArrayKeys
));
- %SetProperty($Array.prototype, symbolIterator, ArrayValues, DONT_ENUM);
+ %AddProperty($Array.prototype, symbolIterator, ArrayValues, DONT_ENUM);
}
ExtendArrayPrototype();
endmacro
macro EXTEND_TYPED_ARRAY(NAME)
- %SetProperty($NAME.prototype, 'entries', ArrayEntries, DONT_ENUM);
- %SetProperty($NAME.prototype, 'values', ArrayValues, DONT_ENUM);
- %SetProperty($NAME.prototype, 'keys', ArrayKeys, DONT_ENUM);
- %SetProperty($NAME.prototype, symbolIterator, ArrayValues, DONT_ENUM);
+ %AddProperty($NAME.prototype, 'entries', ArrayEntries, DONT_ENUM);
+ %AddProperty($NAME.prototype, 'values', ArrayValues, DONT_ENUM);
+ %AddProperty($NAME.prototype, 'keys', ArrayKeys, DONT_ENUM);
+ %AddProperty($NAME.prototype, symbolIterator, ArrayValues, DONT_ENUM);
endmacro
TYPED_ARRAYS(EXTEND_TYPED_ARRAY)
for (var i = 0; i < m; i++) {
// Use SetProperty rather than a direct keyed store to ensure that the store
// site doesn't become poisened with an elements transition KeyedStoreIC.
- %SetProperty(array, i+n, %_Arguments(i), 0, kStrictMode);
+ %SetProperty(array, i+n, %_Arguments(i), kStrictMode);
}
var new_length = n + m;
// Set up non-enumerable constructor property on the Array.prototype
// object.
- %SetProperty($Array.prototype, "constructor", $Array, DONT_ENUM);
+ %AddProperty($Array.prototype, "constructor", $Array, DONT_ENUM);
// Set up non-enumerable functions on the Array object.
InstallFunctions($Array, DONT_ENUM, $Array(
%FunctionSetPrototype($ArrayBuffer, new $Object());
// Set up the constructor property on the ArrayBuffer prototype object.
- %SetProperty($ArrayBuffer.prototype, "constructor", $ArrayBuffer, DONT_ENUM);
+ %AddProperty($ArrayBuffer.prototype, "constructor", $ArrayBuffer, DONT_ENUM);
InstallGetter($ArrayBuffer.prototype, "byteLength", ArrayBufferGetByteLen);
native_context()->set_security_token(*inner_global);
static const PropertyAttributes attributes =
static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE);
- Runtime::ForceSetObjectProperty(builtins_global,
- factory()->InternalizeOneByteString(
- STATIC_ASCII_VECTOR("global")),
- inner_global,
- attributes).Assert();
+ Runtime::DefineObjectProperty(builtins_global,
+ factory()->InternalizeOneByteString(
+ STATIC_ASCII_VECTOR("global")),
+ inner_global,
+ attributes).Assert();
// Set up the reference from the global object to the builtins object.
JSGlobalObject::cast(*inner_global)->set_builtins(*builtins_global);
TransferNamedProperties(inner_global_from_snapshot, inner_global);
Utils::OpenHandle(*buffer)->set_should_be_freed(true);
v8::Local<v8::Uint32Array> ta = v8::Uint32Array::New(buffer, 0, num_elems);
Handle<JSBuiltinsObject> builtins(native_context()->builtins());
- Runtime::ForceSetObjectProperty(builtins,
- factory()->InternalizeOneByteString(
- STATIC_ASCII_VECTOR("rngstate")),
- Utils::OpenHandle(*ta),
- NONE).Assert();
+ Runtime::DefineObjectProperty(builtins,
+ factory()->InternalizeOneByteString(
+ STATIC_ASCII_VECTOR("rngstate")),
+ Utils::OpenHandle(*ta),
+ NONE).Assert();
// Initialize trigonometric lookup tables and constants.
const int table_num_bytes = TrigonometricLookupTable::table_num_bytes();
v8::Local<v8::Float64Array> cos_table = v8::Float64Array::New(
cos_buffer, 0, TrigonometricLookupTable::table_size());
- Runtime::ForceSetObjectProperty(builtins,
- factory()->InternalizeOneByteString(
- STATIC_ASCII_VECTOR("kSinTable")),
- Utils::OpenHandle(*sin_table),
- NONE).Assert();
- Runtime::ForceSetObjectProperty(
+ Runtime::DefineObjectProperty(builtins,
+ factory()->InternalizeOneByteString(
+ STATIC_ASCII_VECTOR("kSinTable")),
+ Utils::OpenHandle(*sin_table),
+ NONE).Assert();
+ Runtime::DefineObjectProperty(
builtins,
factory()->InternalizeOneByteString(
STATIC_ASCII_VECTOR("kCosXIntervalTable")),
Utils::OpenHandle(*cos_table),
NONE).Assert();
- Runtime::ForceSetObjectProperty(
+ Runtime::DefineObjectProperty(
builtins,
factory()->InternalizeOneByteString(
STATIC_ASCII_VECTOR("kSamples")),
factory()->NewHeapNumber(
TrigonometricLookupTable::samples()),
NONE).Assert();
- Runtime::ForceSetObjectProperty(
+ Runtime::DefineObjectProperty(
builtins,
factory()->InternalizeOneByteString(
STATIC_ASCII_VECTOR("kIndexConvert")),
));
%FunctionSetName(SetIteratorSymbolIterator, '[Symbol.iterator]');
- %SetProperty(SetIterator.prototype, symbolIterator,
+ %AddProperty(SetIterator.prototype, symbolIterator,
SetIteratorSymbolIterator, DONT_ENUM);
}
'values', SetValues
));
- %SetProperty($Set.prototype, symbolIterator, SetValues,
- DONT_ENUM);
+ %AddProperty($Set.prototype, symbolIterator, SetValues, DONT_ENUM);
}
ExtendSetPrototype();
));
%FunctionSetName(MapIteratorSymbolIterator, '[Symbol.iterator]');
- %SetProperty(MapIterator.prototype, symbolIterator,
+ %AddProperty(MapIterator.prototype, symbolIterator,
MapIteratorSymbolIterator, DONT_ENUM);
}
'values', MapValues
));
- %SetProperty($Map.prototype, symbolIterator, MapEntries,
- DONT_ENUM);
+ %AddProperty($Map.prototype, symbolIterator, MapEntries, DONT_ENUM);
}
ExtendMapPrototype();
%SetCode($Set, SetConstructor);
%FunctionSetPrototype($Set, new $Object());
- %SetProperty($Set.prototype, "constructor", $Set, DONT_ENUM);
+ %AddProperty($Set.prototype, "constructor", $Set, DONT_ENUM);
%FunctionSetLength(SetForEach, 1);
%SetCode($Map, MapConstructor);
%FunctionSetPrototype($Map, new $Object());
- %SetProperty($Map.prototype, "constructor", $Map, DONT_ENUM);
+ %AddProperty($Map.prototype, "constructor", $Map, DONT_ENUM);
%FunctionSetLength(MapForEach, 1);
));
// Set up non-enumerable constructor property of the Date prototype object.
- %SetProperty($Date.prototype, "constructor", $Date, DONT_ENUM);
+ %AddProperty($Date.prototype, "constructor", $Date, DONT_ENUM);
// Set up non-enumerable functions of the Date prototype object and
// set their names.
["next", GeneratorObjectNext,
"throw", GeneratorObjectThrow]);
%FunctionSetName(GeneratorObjectIterator, '[Symbol.iterator]');
- %SetProperty(GeneratorObjectPrototype, symbolIterator, GeneratorObjectIterator,
- DONT_ENUM | DONT_DELETE | READ_ONLY);
- %SetProperty(GeneratorObjectPrototype, "constructor",
- GeneratorFunctionPrototype, DONT_ENUM | DONT_DELETE | READ_ONLY);
+ %AddProperty(GeneratorObjectPrototype, symbolIterator,
+ GeneratorObjectIterator, DONT_ENUM | DONT_DELETE | READ_ONLY);
+ %AddProperty(GeneratorObjectPrototype, "constructor",
+ GeneratorFunctionPrototype, DONT_ENUM | DONT_DELETE | READ_ONLY);
%SetPrototype(GeneratorFunctionPrototype, $Function.prototype);
%SetCode(GeneratorFunctionPrototype, GeneratorFunctionPrototypeConstructor);
- %SetProperty(GeneratorFunctionPrototype, "constructor",
- GeneratorFunction, DONT_ENUM | DONT_DELETE | READ_ONLY);
+ %AddProperty(GeneratorFunctionPrototype, "constructor",
+ GeneratorFunction, DONT_ENUM | DONT_DELETE | READ_ONLY);
%SetPrototype(GeneratorFunction, $Function);
%SetCode(GeneratorFunction, GeneratorFunctionConstructor);
}
*
* @constructor
*/
-%SetProperty(Intl, 'Collator', function() {
+%AddProperty(Intl, 'Collator', function() {
var locales = %_Arguments(0);
var options = %_Arguments(1);
/**
* Collator resolvedOptions method.
*/
-%SetProperty(Intl.Collator.prototype, 'resolvedOptions', function() {
+%AddProperty(Intl.Collator.prototype, 'resolvedOptions', function() {
if (%_IsConstructCall()) {
throw new $TypeError(ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR);
}
* order in the returned list as in the input list.
* Options are optional parameter.
*/
-%SetProperty(Intl.Collator, 'supportedLocalesOf', function(locales) {
+%AddProperty(Intl.Collator, 'supportedLocalesOf', function(locales) {
if (%_IsConstructCall()) {
throw new $TypeError(ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR);
}
*
* @constructor
*/
-%SetProperty(Intl, 'NumberFormat', function() {
+%AddProperty(Intl, 'NumberFormat', function() {
var locales = %_Arguments(0);
var options = %_Arguments(1);
/**
* NumberFormat resolvedOptions method.
*/
-%SetProperty(Intl.NumberFormat.prototype, 'resolvedOptions', function() {
+%AddProperty(Intl.NumberFormat.prototype, 'resolvedOptions', function() {
if (%_IsConstructCall()) {
throw new $TypeError(ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR);
}
* order in the returned list as in the input list.
* Options are optional parameter.
*/
-%SetProperty(Intl.NumberFormat, 'supportedLocalesOf', function(locales) {
+%AddProperty(Intl.NumberFormat, 'supportedLocalesOf', function(locales) {
if (%_IsConstructCall()) {
throw new $TypeError(ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR);
}
*
* @constructor
*/
-%SetProperty(Intl, 'DateTimeFormat', function() {
+%AddProperty(Intl, 'DateTimeFormat', function() {
var locales = %_Arguments(0);
var options = %_Arguments(1);
/**
* DateTimeFormat resolvedOptions method.
*/
-%SetProperty(Intl.DateTimeFormat.prototype, 'resolvedOptions', function() {
+%AddProperty(Intl.DateTimeFormat.prototype, 'resolvedOptions', function() {
if (%_IsConstructCall()) {
throw new $TypeError(ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR);
}
* order in the returned list as in the input list.
* Options are optional parameter.
*/
-%SetProperty(Intl.DateTimeFormat, 'supportedLocalesOf', function(locales) {
+%AddProperty(Intl.DateTimeFormat, 'supportedLocalesOf', function(locales) {
if (%_IsConstructCall()) {
throw new $TypeError(ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR);
}
*
* @constructor
*/
-%SetProperty(Intl, 'v8BreakIterator', function() {
+%AddProperty(Intl, 'v8BreakIterator', function() {
var locales = %_Arguments(0);
var options = %_Arguments(1);
/**
* BreakIterator resolvedOptions method.
*/
-%SetProperty(Intl.v8BreakIterator.prototype, 'resolvedOptions', function() {
+%AddProperty(Intl.v8BreakIterator.prototype, 'resolvedOptions', function() {
if (%_IsConstructCall()) {
throw new $TypeError(ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR);
}
* order in the returned list as in the input list.
* Options are optional parameter.
*/
-%SetProperty(Intl.v8BreakIterator, 'supportedLocalesOf', function(locales) {
+%AddProperty(Intl.v8BreakIterator, 'supportedLocalesOf', function(locales) {
if (%_IsConstructCall()) {
throw new $TypeError(ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR);
}
VisitForStackValue(value);
if (property->emit_store()) {
__ push(Immediate(Smi::FromInt(NONE))); // PropertyAttributes
- __ CallRuntime(Runtime::kSetProperty, 4);
+ __ CallRuntime(Runtime::kAddProperty, 4);
} else {
__ Drop(3);
}
EmitAccessor(it->second->getter);
EmitAccessor(it->second->setter);
__ push(Immediate(Smi::FromInt(NONE)));
- __ CallRuntime(Runtime::kDefineOrRedefineAccessorProperty, 5);
+ __ CallRuntime(Runtime::kDefineAccessorPropertyUnchecked, 5);
}
if (expr->has_function()) {
__ push(edx);
__ push(ecx);
__ push(eax);
- __ push(Immediate(Smi::FromInt(NONE))); // PropertyAttributes
__ push(Immediate(Smi::FromInt(strict_mode)));
__ push(ebx); // return address
// Do tail-call to runtime routine.
- __ TailCallRuntime(Runtime::kSetProperty, 5, 1);
+ __ TailCallRuntime(Runtime::kSetProperty, 4, 1);
}
__ push(edx);
__ push(ecx);
__ push(eax);
- __ push(Immediate(Smi::FromInt(NONE))); // PropertyAttributes
__ push(Immediate(Smi::FromInt(strict_mode))); // Strict mode.
__ push(ebx); // return address
// Do tail-call to runtime routine.
- __ TailCallRuntime(Runtime::kSetProperty, 5, 1);
+ __ TailCallRuntime(Runtime::kSetProperty, 4, 1);
}
isolate(),
result,
Runtime::SetObjectProperty(
- isolate(), object, key, value, NONE, strict_mode()),
+ isolate(), object, key, value, strict_mode()),
Object);
return result;
}
isolate(),
store_handle,
Runtime::SetObjectProperty(
- isolate(), object, key, value, NONE, strict_mode()),
+ isolate(), object, key, value, strict_mode()),
Object);
}
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, result,
Runtime::SetObjectProperty(
- isolate, object, key, value, NONE, strict_mode));
+ isolate, object, key, value, strict_mode));
return *result;
}
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, result,
Runtime::SetObjectProperty(
- isolate, object, key, value, NONE, strict_mode));
+ isolate, object, key, value, strict_mode));
return *result;
}
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, result,
Runtime::SetObjectProperty(
- isolate, object, key, value, NONE, strict_mode));
+ isolate, object, key, value, strict_mode));
return *result;
}
%CheckIsBootstrapping();
%SetPrototype($Math, $Object.prototype);
- %SetProperty(global, "Math", $Math, DONT_ENUM);
+ %AddProperty(global, "Math", $Math, DONT_ENUM);
%FunctionSetInstanceClassName(MathConstructor, 'Math');
// Set up math constants.
* Set up the Script function and constructor.
*/
%FunctionSetInstanceClassName(Script, 'Script');
-%SetProperty(Script.prototype, 'constructor', Script,
+%AddProperty(Script.prototype, 'constructor', Script,
DONT_ENUM | DONT_DELETE | READ_ONLY);
%SetCode(Script, function(x) {
// Script objects can only be created by the VM.
// holder of this setter, the accessor pair is turned into a data property.
var setter = function(v) {
// Set data property on the receiver (not necessarily holder).
- %DefineOrRedefineDataProperty(this, 'stack', v, NONE);
+ %DefineDataPropertyUnchecked(this, 'stack', v, NONE);
if (this === obj) {
// Release context values if holder is the same as the receiver.
stack = error_string = UNDEFINED;
// Stack is still a raw array awaiting to be formatted.
var result = FormatStackTrace(obj, error_string, GetStackFrames(stack));
// Replace this accessor to return result directly.
- %DefineOrRedefineAccessorProperty(
+ %DefineAccessorPropertyUnchecked(
obj, 'stack', function() { return result }, setter, DONT_ENUM);
// Release context values.
stack = error_string = UNDEFINED;
return result;
};
- %DefineOrRedefineAccessorProperty(obj, 'stack', getter, setter, DONT_ENUM);
+ %DefineAccessorPropertyUnchecked(obj, 'stack', getter, setter, DONT_ENUM);
}
// effects when overwriting the error functions from
// user code.
var name = f.name;
- %SetProperty(global, name, f, DONT_ENUM);
- %SetProperty(builtins, '$' + name, f, DONT_ENUM | DONT_DELETE | READ_ONLY);
+ %AddProperty(global, name, f, DONT_ENUM);
+ %AddProperty(builtins, '$' + name, f,
+ DONT_ENUM | DONT_DELETE | READ_ONLY);
// Configure the error function.
if (name == 'Error') {
// The prototype of the Error object must itself be an error.
%FunctionSetPrototype(f, new $Error());
}
%FunctionSetInstanceClassName(f, 'Error');
- %SetProperty(f.prototype, 'constructor', f, DONT_ENUM);
- %SetProperty(f.prototype, "name", name, DONT_ENUM);
+ %AddProperty(f.prototype, 'constructor', f, DONT_ENUM);
+ %AddProperty(f.prototype, "name", name, DONT_ENUM);
%SetCode(f, function(m) {
if (%_IsConstructCall()) {
// Define all the expected properties directly on the error
// object. This avoids going through getters and setters defined
// on prototype objects.
- %IgnoreAttributesAndSetProperty(this, 'stack', UNDEFINED, DONT_ENUM);
+ %AddProperty(this, 'stack', UNDEFINED, DONT_ENUM);
if (!IS_UNDEFINED(m)) {
- %IgnoreAttributesAndSetProperty(
- this, 'message', ToString(m), DONT_ENUM);
+ %AddProperty(this, 'message', ToString(m), DONT_ENUM);
}
captureStackTrace(this, f);
} else {
$Error.captureStackTrace = captureStackTrace;
-%SetProperty($Error.prototype, 'message', '', DONT_ENUM);
+%AddProperty($Error.prototype, 'message', '', DONT_ENUM);
// Global list of error objects visited during ErrorToString. This is
// used to detect cycles in error toString formatting.
// Set the 'stack' property on the receiver. If the receiver is the same as
// holder of this setter, the accessor pair is turned into a data property.
var setter = function(v) {
- %DefineOrRedefineDataProperty(this, 'stack', v, NONE);
+ %DefineDataPropertyUnchecked(this, 'stack', v, NONE);
// Tentatively clear the hidden property. If the receiver is the same as
// holder, we release the raw stack trace this way.
%GetAndClearOverflowedStackTrace(this);
var result = FormatStackTrace(holder, error_string, GetStackFrames(stack));
// Replace this accessor to return result directly.
- %DefineOrRedefineAccessorProperty(
+ %DefineAccessorPropertyUnchecked(
holder, 'stack', function() { return result }, setter, DONT_ENUM);
return result;
};
- %DefineOrRedefineAccessorProperty(
+ %DefineAccessorPropertyUnchecked(
boilerplate, 'stack', getter, setter, DONT_ENUM);
return boilerplate;
if (property->emit_store()) {
__ li(a0, Operand(Smi::FromInt(NONE))); // PropertyAttributes.
__ push(a0);
- __ CallRuntime(Runtime::kSetProperty, 4);
+ __ CallRuntime(Runtime::kAddProperty, 4);
} else {
__ Drop(3);
}
EmitAccessor(it->second->setter);
__ li(a0, Operand(Smi::FromInt(NONE)));
__ push(a0);
- __ CallRuntime(Runtime::kDefineOrRedefineAccessorProperty, 5);
+ __ CallRuntime(Runtime::kDefineAccessorPropertyUnchecked, 5);
}
if (expr->has_function()) {
for (var prop in changeRecord) {
if (prop === 'object' || (hasType && prop === 'type')) continue;
- %DefineOrRedefineDataProperty(newRecord, prop, changeRecord[prop],
- READ_ONLY + DONT_DELETE);
+ %AddProperty(newRecord, prop, changeRecord[prop], READ_ONLY + DONT_DELETE);
}
ObjectFreezeJS(newRecord);
// Install exported functions.
%CheckIsBootstrapping();
- %SetProperty(global, 'Promise', $Promise, DONT_ENUM);
+ %AddProperty(global, 'Promise', $Promise, DONT_ENUM);
InstallFunctions($Promise, DONT_ENUM, [
"defer", PromiseDeferred,
"accept", PromiseResolved,
function SetUpRegExp() {
%CheckIsBootstrapping();
%FunctionSetInstanceClassName($RegExp, 'RegExp');
- %SetProperty($RegExp.prototype, 'constructor', $RegExp, DONT_ENUM);
+ %AddProperty($RegExp.prototype, 'constructor', $RegExp, DONT_ENUM);
%SetCode($RegExp, RegExpConstructor);
InstallFunctions($RegExp.prototype, DONT_ENUM, $Array(
};
%OptimizeObjectForAddingMultipleProperties($RegExp, 22);
- %DefineOrRedefineAccessorProperty($RegExp, 'input', RegExpGetInput,
- RegExpSetInput, DONT_DELETE);
- %DefineOrRedefineAccessorProperty($RegExp, '$_', RegExpGetInput,
- RegExpSetInput, DONT_ENUM | DONT_DELETE);
- %DefineOrRedefineAccessorProperty($RegExp, '$input', RegExpGetInput,
- RegExpSetInput, DONT_ENUM | DONT_DELETE);
+ %DefineAccessorPropertyUnchecked($RegExp, 'input', RegExpGetInput,
+ RegExpSetInput, DONT_DELETE);
+ %DefineAccessorPropertyUnchecked($RegExp, '$_', RegExpGetInput,
+ RegExpSetInput, DONT_ENUM | DONT_DELETE);
+ %DefineAccessorPropertyUnchecked($RegExp, '$input', RegExpGetInput,
+ RegExpSetInput, DONT_ENUM | DONT_DELETE);
// The properties multiline and $* are aliases for each other. When this
// value is set in SpiderMonkey, the value it is set to is coerced to a
var RegExpGetMultiline = function() { return multiline; };
var RegExpSetMultiline = function(flag) { multiline = flag ? true : false; };
- %DefineOrRedefineAccessorProperty($RegExp, 'multiline', RegExpGetMultiline,
- RegExpSetMultiline, DONT_DELETE);
- %DefineOrRedefineAccessorProperty($RegExp, '$*', RegExpGetMultiline,
- RegExpSetMultiline,
- DONT_ENUM | DONT_DELETE);
+ %DefineAccessorPropertyUnchecked($RegExp, 'multiline', RegExpGetMultiline,
+ RegExpSetMultiline, DONT_DELETE);
+ %DefineAccessorPropertyUnchecked($RegExp, '$*', RegExpGetMultiline,
+ RegExpSetMultiline,
+ DONT_ENUM | DONT_DELETE);
var NoOpSetter = function(ignored) {};
// Static properties set by a successful match.
- %DefineOrRedefineAccessorProperty($RegExp, 'lastMatch', RegExpGetLastMatch,
- NoOpSetter, DONT_DELETE);
- %DefineOrRedefineAccessorProperty($RegExp, '$&', RegExpGetLastMatch,
- NoOpSetter, DONT_ENUM | DONT_DELETE);
- %DefineOrRedefineAccessorProperty($RegExp, 'lastParen', RegExpGetLastParen,
- NoOpSetter, DONT_DELETE);
- %DefineOrRedefineAccessorProperty($RegExp, '$+', RegExpGetLastParen,
- NoOpSetter, DONT_ENUM | DONT_DELETE);
- %DefineOrRedefineAccessorProperty($RegExp, 'leftContext',
- RegExpGetLeftContext, NoOpSetter,
- DONT_DELETE);
- %DefineOrRedefineAccessorProperty($RegExp, '$`', RegExpGetLeftContext,
- NoOpSetter, DONT_ENUM | DONT_DELETE);
- %DefineOrRedefineAccessorProperty($RegExp, 'rightContext',
- RegExpGetRightContext, NoOpSetter,
- DONT_DELETE);
- %DefineOrRedefineAccessorProperty($RegExp, "$'", RegExpGetRightContext,
- NoOpSetter, DONT_ENUM | DONT_DELETE);
+ %DefineAccessorPropertyUnchecked($RegExp, 'lastMatch', RegExpGetLastMatch,
+ NoOpSetter, DONT_DELETE);
+ %DefineAccessorPropertyUnchecked($RegExp, '$&', RegExpGetLastMatch,
+ NoOpSetter, DONT_ENUM | DONT_DELETE);
+ %DefineAccessorPropertyUnchecked($RegExp, 'lastParen', RegExpGetLastParen,
+ NoOpSetter, DONT_DELETE);
+ %DefineAccessorPropertyUnchecked($RegExp, '$+', RegExpGetLastParen,
+ NoOpSetter, DONT_ENUM | DONT_DELETE);
+ %DefineAccessorPropertyUnchecked($RegExp, 'leftContext',
+ RegExpGetLeftContext, NoOpSetter,
+ DONT_DELETE);
+ %DefineAccessorPropertyUnchecked($RegExp, '$`', RegExpGetLeftContext,
+ NoOpSetter, DONT_ENUM | DONT_DELETE);
+ %DefineAccessorPropertyUnchecked($RegExp, 'rightContext',
+ RegExpGetRightContext, NoOpSetter,
+ DONT_DELETE);
+ %DefineAccessorPropertyUnchecked($RegExp, "$'", RegExpGetRightContext,
+ NoOpSetter, DONT_ENUM | DONT_DELETE);
for (var i = 1; i < 10; ++i) {
- %DefineOrRedefineAccessorProperty($RegExp, '$' + i,
- RegExpMakeCaptureGetter(i), NoOpSetter,
- DONT_DELETE);
+ %DefineAccessorPropertyUnchecked($RegExp, '$' + i,
+ RegExpMakeCaptureGetter(i), NoOpSetter,
+ DONT_DELETE);
}
%ToFastProperties($RegExp);
}
if (key->IsInternalizedString()) {
if (Handle<String>::cast(key)->AsArrayIndex(&element_index)) {
// Array index as string (uint32).
- maybe_result = JSObject::SetOwnElement(
- boilerplate, element_index, value, SLOPPY);
+ if (value->IsUninitialized()) {
+ maybe_result = value;
+ } else {
+ maybe_result = JSObject::SetOwnElement(
+ boilerplate, element_index, value, SLOPPY);
+ }
} else {
Handle<String> name(String::cast(*key));
ASSERT(!name->AsArrayIndex(&element_index));
}
} else if (key->ToArrayIndex(&element_index)) {
// Array index (uint32).
- maybe_result = JSObject::SetOwnElement(
- boilerplate, element_index, value, SLOPPY);
+ if (value->IsUninitialized()) {
+ maybe_result = value;
+ } else {
+ maybe_result = JSObject::SetOwnElement(
+ boilerplate, element_index, value, SLOPPY);
+ }
} else {
// Non-uint32 number.
ASSERT(key->IsNumber());
}
-// Transform getter or setter into something DefineAccessor can handle.
-static Handle<Object> InstantiateAccessorComponent(Isolate* isolate,
- Handle<Object> component) {
- if (component->IsUndefined()) return isolate->factory()->null_value();
- Handle<FunctionTemplateInfo> info =
- Handle<FunctionTemplateInfo>::cast(component);
- return Utils::OpenHandle(*Utils::ToLocal(info)->GetFunction());
-}
-
-
-RUNTIME_FUNCTION(Runtime_SetAccessorProperty) {
- HandleScope scope(isolate);
- ASSERT(args.length() == 5);
- CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
- CONVERT_ARG_HANDLE_CHECKED(Name, name, 1);
- CONVERT_ARG_HANDLE_CHECKED(Object, getter, 2);
- CONVERT_ARG_HANDLE_CHECKED(Object, setter, 3);
- CONVERT_SMI_ARG_CHECKED(attribute, 4);
- RUNTIME_ASSERT(getter->IsUndefined() || getter->IsFunctionTemplateInfo());
- RUNTIME_ASSERT(setter->IsUndefined() || setter->IsFunctionTemplateInfo());
- RUNTIME_ASSERT(PropertyDetails::AttributesField::is_valid(
- static_cast<PropertyAttributes>(attribute)));
- JSObject::DefineAccessor(object,
- name,
- InstantiateAccessorComponent(isolate, getter),
- InstantiateAccessorComponent(isolate, setter),
- static_cast<PropertyAttributes>(attribute));
- return isolate->heap()->undefined_value();
-}
-
-
static Object* ThrowRedeclarationError(Isolate* isolate, Handle<String> name) {
HandleScope scope(isolate);
Handle<Object> args[1] = { name };
// Steps 9c & 12 - replace an existing data property with an accessor property.
// Step 12 - update an existing accessor property with an accessor or generic
// descriptor.
-RUNTIME_FUNCTION(Runtime_DefineOrRedefineAccessorProperty) {
+RUNTIME_FUNCTION(Runtime_DefineAccessorPropertyUnchecked) {
HandleScope scope(isolate);
ASSERT(args.length() == 5);
CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0);
// Steps 9b & 12 - replace an existing accessor property with a data property.
// Step 12 - update an existing data property with a data or generic
// descriptor.
-RUNTIME_FUNCTION(Runtime_DefineOrRedefineDataProperty) {
+RUNTIME_FUNCTION(Runtime_DefineDataPropertyUnchecked) {
HandleScope scope(isolate);
ASSERT(args.length() == 4);
CONVERT_ARG_HANDLE_CHECKED(JSObject, js_object, 0);
Handle<Object> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, result,
- Runtime::ForceSetObjectProperty(
+ Runtime::DefineObjectProperty(
js_object, name, obj_value, attr,
JSReceiver::CERTAINLY_NOT_STORE_FROM_KEYED));
return *result;
Handle<Object> object,
Handle<Object> key,
Handle<Object> value,
- PropertyAttributes attr,
- StrictMode strict_mode) {
- SetPropertyMode set_mode = attr == NONE ? SET_PROPERTY : DEFINE_PROPERTY;
-
+ StrictMode strict_mode,
+ PropertyAttributes attrs) {
if (object->IsUndefined() || object->IsNull()) {
Handle<Object> args[2] = { key, object };
Handle<Object> error =
}
Handle<Name> name = Handle<Name>::cast(name_object);
return JSReceiver::SetProperty(Handle<JSProxy>::cast(object), name, value,
- attr,
- strict_mode);
+ attrs, strict_mode);
}
// If the object isn't a JavaScript object, we ignore the store.
}
MaybeHandle<Object> result = JSObject::SetElement(
- js_object, index, value, attr, strict_mode, true, set_mode);
+ js_object, index, value, attrs, strict_mode, true, SET_PROPERTY);
JSObject::ValidateElements(js_object);
return result.is_null() ? result : value;
isolate, value, Execution::ToNumber(isolate, value), Object);
}
}
- return JSObject::SetElement(js_object, index, value, attr,
- strict_mode, true, set_mode);
+ return JSObject::SetElement(js_object, index, value, attrs,
+ strict_mode, true, SET_PROPERTY);
} else {
if (name->IsString()) name = String::Flatten(Handle<String>::cast(name));
- return JSReceiver::SetProperty(js_object, name, value, attr, strict_mode);
+ return JSReceiver::SetProperty(
+ js_object, name, value, attrs, strict_mode);
}
}
Handle<String> name = Handle<String>::cast(converted);
if (name->AsArrayIndex(&index)) {
- return JSObject::SetElement(js_object, index, value, attr,
- strict_mode, true, set_mode);
+ return JSObject::SetElement(js_object, index, value, attrs,
+ strict_mode, true, SET_PROPERTY);
} else {
- return JSReceiver::SetProperty(js_object, name, value, attr, strict_mode);
+ return JSReceiver::SetProperty(js_object, name, value, attrs, strict_mode);
}
}
-MaybeHandle<Object> Runtime::ForceSetObjectProperty(
+MaybeHandle<Object> Runtime::DefineObjectProperty(
Handle<JSObject> js_object,
Handle<Object> key,
Handle<Object> value,
}
-RUNTIME_FUNCTION(Runtime_SetProperty) {
+RUNTIME_FUNCTION(Runtime_AddProperty) {
HandleScope scope(isolate);
- RUNTIME_ASSERT(args.length() == 4 || args.length() == 5);
+ RUNTIME_ASSERT(args.length() == 4);
- CONVERT_ARG_HANDLE_CHECKED(Object, object, 0);
+ CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, key, 1);
CONVERT_ARG_HANDLE_CHECKED(Object, value, 2);
CONVERT_SMI_ARG_CHECKED(unchecked_attributes, 3);
PropertyAttributes attributes =
static_cast<PropertyAttributes>(unchecked_attributes);
- StrictMode strict_mode = SLOPPY;
- if (args.length() == 5) {
- CONVERT_STRICT_MODE_ARG_CHECKED(strict_mode_arg, 4);
- strict_mode = strict_mode_arg;
+#ifdef DEBUG
+ if (key->IsName()) {
+ LookupIterator it(object, Handle<Name>::cast(key),
+ LookupIterator::CHECK_OWN);
+ JSReceiver::GetPropertyAttributes(&it);
+ RUNTIME_ASSERT(!it.IsFound());
+ } else {
+ uint32_t index = 0;
+ RUNTIME_ASSERT(key->ToArrayIndex(&index));
+ RUNTIME_ASSERT(!JSReceiver::HasOwnElement(object, index));
}
+#endif
Handle<Object> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, result,
- Runtime::SetObjectProperty(
- isolate, object, key, value, attributes, strict_mode));
+ Runtime::DefineObjectProperty(object, key, value, attributes));
+ return *result;
+}
+
+
+RUNTIME_FUNCTION(Runtime_SetProperty) {
+ HandleScope scope(isolate);
+ RUNTIME_ASSERT(args.length() == 4);
+
+ CONVERT_ARG_HANDLE_CHECKED(Object, object, 0);
+ CONVERT_ARG_HANDLE_CHECKED(Object, key, 1);
+ CONVERT_ARG_HANDLE_CHECKED(Object, value, 2);
+ CONVERT_STRICT_MODE_ARG_CHECKED(strict_mode_arg, 3);
+ StrictMode strict_mode = strict_mode_arg;
+
+ Handle<Object> result;
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
+ isolate, result,
+ Runtime::SetObjectProperty(isolate, object, key, value, strict_mode));
return *result;
}
}
-// Set an own property, even if it is READ_ONLY. If the property does not
-// exist, it will be added with attributes NONE.
-RUNTIME_FUNCTION(Runtime_IgnoreAttributesAndSetProperty) {
- HandleScope scope(isolate);
- RUNTIME_ASSERT(args.length() == 3 || args.length() == 4);
- CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
- CONVERT_ARG_HANDLE_CHECKED(Name, name, 1);
- CONVERT_ARG_HANDLE_CHECKED(Object, value, 2);
- // Compute attributes.
- PropertyAttributes attributes = NONE;
- if (args.length() == 4) {
- CONVERT_SMI_ARG_CHECKED(unchecked_value, 3);
- // Only attribute bits should be set.
- RUNTIME_ASSERT(
- (unchecked_value & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0);
- attributes = static_cast<PropertyAttributes>(unchecked_value);
- }
- Handle<Object> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result,
- JSObject::SetOwnPropertyIgnoreAttributes(
- object, name, value, attributes));
- return *result;
-}
-
-
RUNTIME_FUNCTION(Runtime_DeleteProperty) {
HandleScope scope(isolate);
ASSERT(args.length() == 3);
RETURN_ON_EXCEPTION(
isolate,
- Runtime::SetObjectProperty(isolate, target, name, value, NONE, SLOPPY),
+ Runtime::SetObjectProperty(isolate, target, name, value, SLOPPY),
JSObject);
}
RETURN_ON_EXCEPTION(
isolate,
- Runtime::SetObjectProperty(isolate, target, name, value, NONE, SLOPPY),
+ Runtime::SetObjectProperty(isolate, target, name, value, SLOPPY),
JSObject);
}
isolate, value, Object::GetPropertyOrElement(ext, key), JSObject);
RETURN_ON_EXCEPTION(
isolate,
- Runtime::SetObjectProperty(
- isolate, target, key, value, NONE, SLOPPY),
+ Runtime::SetObjectProperty(isolate, target, key, value, SLOPPY),
JSObject);
}
}
// We don't expect this to do anything except replacing
// property value.
Runtime::SetObjectProperty(isolate, ext, variable_name, new_value,
- NONE, SLOPPY).Assert();
+ SLOPPY).Assert();
return true;
}
}
isolate, value, Object::GetPropertyOrElement(ext, key), JSObject);
RETURN_ON_EXCEPTION(
isolate,
- Runtime::SetObjectProperty(
- isolate, closure_scope, key, value, NONE, SLOPPY),
+ Runtime::DefineObjectProperty(closure_scope, key, value, NONE),
JSObject);
}
}
Handle<JSObject> ext(JSObject::cast(context->extension()));
if (JSReceiver::HasProperty(ext, variable_name)) {
// We don't expect this to do anything except replacing property value.
- Runtime::SetObjectProperty(isolate, ext, variable_name, new_value,
- NONE, SLOPPY).Assert();
+ Runtime::DefineObjectProperty(
+ ext, variable_name, new_value, NONE).Assert();
return true;
}
}
isolate->factory()->NewJSObject(isolate->object_function());
RETURN_ON_EXCEPTION(
isolate,
- Runtime::SetObjectProperty(isolate, catch_scope, name, thrown_object,
- NONE, SLOPPY),
+ Runtime::DefineObjectProperty(catch_scope, name, thrown_object, NONE),
JSObject);
return catch_scope;
}
Handle<String> arguments_str = isolate->factory()->arguments_string();
RETURN_ON_EXCEPTION(
isolate,
- Runtime::SetObjectProperty(
- isolate, target, arguments_str, arguments, ::NONE, SLOPPY),
+ Runtime::DefineObjectProperty(target, arguments_str, arguments, NONE),
JSObject);
return target;
}
F(GetTemplateField, 2, 1) \
F(DisableAccessChecks, 1, 1) \
F(EnableAccessChecks, 1, 1) \
- F(SetAccessorProperty, 5, 1) \
\
/* Dates */ \
F(DateCurrentTime, 0, 1) \
F(GlobalReceiver, 1, 1) \
F(IsAttachedGlobal, 1, 1) \
\
- F(SetProperty, -1 /* 4 or 5 */, 1) \
- F(DefineOrRedefineDataProperty, 4, 1) \
- F(DefineOrRedefineAccessorProperty, 5, 1) \
- F(IgnoreAttributesAndSetProperty, -1 /* 3 or 4 */, 1) \
+ F(AddProperty, 4, 1) \
+ F(SetProperty, 4, 1) \
+ F(DefineDataPropertyUnchecked, 4, 1) \
+ F(DefineAccessorPropertyUnchecked, 5, 1) \
F(GetDataProperty, 2, 1) \
F(SetHiddenProperty, 3, 1) \
\
Handle<Object> object,
uint32_t index);
+ // Do not use SetObjectProperty to configure a property with specific
+ // attributes. The argument will be removed once the API is adapted.
MUST_USE_RESULT static MaybeHandle<Object> SetObjectProperty(
Isolate* isolate,
Handle<Object> object,
Handle<Object> key,
Handle<Object> value,
- PropertyAttributes attr,
- StrictMode strict_mode);
+ StrictMode strict_mode,
+ PropertyAttributes attributes = NONE);
- MUST_USE_RESULT static MaybeHandle<Object> ForceSetObjectProperty(
+ MUST_USE_RESULT static MaybeHandle<Object> DefineObjectProperty(
Handle<JSObject> object,
Handle<Object> key,
Handle<Object> value,
PropertyAttributes attr,
- JSReceiver::StoreFromKeyed store_from_keyed
- = JSReceiver::MAY_BE_STORE_FROM_KEYED);
+ JSReceiver::StoreFromKeyed store_from_keyed =
+ JSReceiver::MAY_BE_STORE_FROM_KEYED);
MUST_USE_RESULT static MaybeHandle<Object> DeleteObjectProperty(
Isolate* isolate,
int context_index = Context::MIN_CONTEXT_SLOTS + i;
RETURN_ON_EXCEPTION_VALUE(
isolate,
- Runtime::SetObjectProperty(
- isolate,
+ Runtime::DefineObjectProperty(
scope_object,
Handle<String>(String::cast(scope_info->get(i + start))),
Handle<Object>(context->get(context_index), isolate),
- ::NONE,
- SLOPPY),
+ ::NONE),
false);
}
return true;
'next', StringIteratorNext
));
%FunctionSetName(StringIteratorIterator, '[Symbol.iterator]');
- %SetProperty(StringIterator.prototype, symbolIterator, StringIteratorIterator,
+ %AddProperty(StringIterator.prototype, symbolIterator, StringIteratorIterator,
DONT_ENUM);
}
SetUpStringIterator();
%CheckIsBootstrapping();
%FunctionSetName(StringPrototypeIterator, '[Symbol.iterator]');
- %SetProperty($String.prototype, symbolIterator, StringPrototypeIterator,
+ %AddProperty($String.prototype, symbolIterator, StringPrototypeIterator,
DONT_ENUM);
}
ExtendStringPrototypeWithIterator();
%FunctionSetPrototype($String, new $String());
// Set up the constructor property on the String prototype object.
- %SetProperty($String.prototype, "constructor", $String, DONT_ENUM);
+ %AddProperty($String.prototype, "constructor", $String, DONT_ENUM);
// Set up the non-enumerable functions on the String object.
InstallFunctions($String, DONT_ENUM, $Array(
"keyFor", SymbolKeyFor
));
- %SetProperty($Symbol.prototype, "constructor", $Symbol, DONT_ENUM);
+ %AddProperty($Symbol.prototype, "constructor", $Symbol, DONT_ENUM);
InstallFunctions($Symbol.prototype, DONT_ENUM, $Array(
"toString", SymbolToString,
"valueOf", SymbolValueOf
%SetCode(global.NAME, NAMEConstructor);
%FunctionSetPrototype(global.NAME, new $Object());
- %SetProperty(global.NAME, "BYTES_PER_ELEMENT", ELEMENT_SIZE,
+ %AddProperty(global.NAME, "BYTES_PER_ELEMENT", ELEMENT_SIZE,
READ_ONLY | DONT_ENUM | DONT_DELETE);
- %SetProperty(global.NAME.prototype,
+ %AddProperty(global.NAME.prototype,
"constructor", global.NAME, DONT_ENUM);
- %SetProperty(global.NAME.prototype,
+ %AddProperty(global.NAME.prototype,
"BYTES_PER_ELEMENT", ELEMENT_SIZE,
READ_ONLY | DONT_ENUM | DONT_DELETE);
InstallGetter(global.NAME.prototype, "buffer", NAME_GetBuffer);
%FunctionSetPrototype($DataView, new $Object);
// Set up constructor property on the DataView prototype.
- %SetProperty($DataView.prototype, "constructor", $DataView, DONT_ENUM);
+ %AddProperty($DataView.prototype, "constructor", $DataView, DONT_ENUM);
InstallGetter($DataView.prototype, "buffer", DataViewGetBufferJS);
InstallGetter($DataView.prototype, "byteOffset", DataViewGetByteOffset);
var f = functions[i + 1];
%FunctionSetName(f, key);
%FunctionRemovePrototype(f);
- %SetProperty(object, key, f, attributes);
+ %AddProperty(object, key, f, attributes);
%SetNativeFlag(f);
}
%ToFastProperties(object);
function InstallGetter(object, name, getter) {
%FunctionSetName(getter, name);
%FunctionRemovePrototype(getter);
- %DefineOrRedefineAccessorProperty(object, name, getter, null, DONT_ENUM);
+ %DefineAccessorPropertyUnchecked(object, name, getter, null, DONT_ENUM);
%SetNativeFlag(getter);
}
%FunctionSetName(setter, name);
%FunctionRemovePrototype(getter);
%FunctionRemovePrototype(setter);
- %DefineOrRedefineAccessorProperty(object, name, getter, setter, DONT_ENUM);
+ %DefineAccessorPropertyUnchecked(object, name, getter, setter, DONT_ENUM);
%SetNativeFlag(getter);
%SetNativeFlag(setter);
}
for (var i = 0; i < constants.length; i += 2) {
var name = constants[i];
var k = constants[i + 1];
- %SetProperty(object, name, k, attributes);
+ %AddProperty(object, name, k, attributes);
}
%ToFastProperties(object);
}
}
if (fields) {
for (var i = 0; i < fields.length; i++) {
- %SetProperty(prototype, fields[i], UNDEFINED, DONT_ENUM | DONT_DELETE);
+ %AddProperty(prototype, fields[i], UNDEFINED, DONT_ENUM | DONT_DELETE);
}
}
for (var i = 0; i < methods.length; i += 2) {
var key = methods[i];
var f = methods[i + 1];
- %SetProperty(prototype, key, f, DONT_ENUM | DONT_DELETE | READ_ONLY);
+ %AddProperty(prototype, key, f, DONT_ENUM | DONT_DELETE | READ_ONLY);
%SetNativeFlag(f);
}
%SetPrototype(prototype, null);
var attributes = DONT_ENUM | DONT_DELETE | READ_ONLY;
// ECMA 262 - 15.1.1.1.
- %SetProperty(global, "NaN", NAN, attributes);
+ %AddProperty(global, "NaN", NAN, attributes);
// ECMA-262 - 15.1.1.2.
- %SetProperty(global, "Infinity", INFINITY, attributes);
+ %AddProperty(global, "Infinity", INFINITY, attributes);
// ECMA-262 - 15.1.1.3.
- %SetProperty(global, "undefined", UNDEFINED, attributes);
+ %AddProperty(global, "undefined", UNDEFINED, attributes);
// Set up non-enumerable function on the global object.
InstallFunctions(global, DONT_ENUM, $Array(
var obj = new $Object();
if (desc.hasValue()) {
- %IgnoreAttributesAndSetProperty(obj, "value", desc.getValue(), NONE);
+ %AddProperty(obj, "value", desc.getValue(), NONE);
}
if (desc.hasWritable()) {
- %IgnoreAttributesAndSetProperty(obj, "writable", desc.isWritable(), NONE);
+ %AddProperty(obj, "writable", desc.isWritable(), NONE);
}
if (desc.hasGetter()) {
- %IgnoreAttributesAndSetProperty(obj, "get", desc.getGet(), NONE);
+ %AddProperty(obj, "get", desc.getGet(), NONE);
}
if (desc.hasSetter()) {
- %IgnoreAttributesAndSetProperty(obj, "set", desc.getSet(), NONE);
+ %AddProperty(obj, "set", desc.getSet(), NONE);
}
if (desc.hasEnumerable()) {
- %IgnoreAttributesAndSetProperty(obj, "enumerable",
- desc.isEnumerable(), NONE);
+ %AddProperty(obj, "enumerable", desc.isEnumerable(), NONE);
}
if (desc.hasConfigurable()) {
- %IgnoreAttributesAndSetProperty(obj, "configurable",
- desc.isConfigurable(), NONE);
+ %AddProperty(obj, "configurable", desc.isConfigurable(), NONE);
}
return obj;
}
value = current.getValue();
}
- %DefineOrRedefineDataProperty(obj, p, value, flag);
+ %DefineDataPropertyUnchecked(obj, p, value, flag);
} else {
// There are 3 cases that lead here:
// Step 4b - defining a new accessor property.
// descriptor.
var getter = desc.hasGetter() ? desc.getGet() : null;
var setter = desc.hasSetter() ? desc.getSet() : null;
- %DefineOrRedefineAccessorProperty(obj, p, getter, setter, flag);
+ %DefineAccessorPropertyUnchecked(obj, p, getter, setter, flag);
}
return true;
}
// Make sure the below call to DefineObjectProperty() doesn't overwrite
// any magic "length" property by removing the value.
// TODO(mstarzinger): This hack should be removed once we have addressed the
- // respective TODO in Runtime_DefineOrRedefineDataProperty.
+ // respective TODO in Runtime_DefineDataPropertyUnchecked.
// For the time being, we need a hack to prevent Object.observe from
// generating two change records.
obj.length = new_length;
%SetNativeFlag($Object);
%SetCode($Object, ObjectConstructor);
- %SetProperty($Object.prototype, "constructor", $Object, DONT_ENUM);
+ %AddProperty($Object.prototype, "constructor", $Object, DONT_ENUM);
// Set up non-enumerable functions on the Object.prototype object.
InstallFunctions($Object.prototype, DONT_ENUM, $Array(
%SetCode($Boolean, BooleanConstructor);
%FunctionSetPrototype($Boolean, new $Boolean(false));
- %SetProperty($Boolean.prototype, "constructor", $Boolean, DONT_ENUM);
+ %AddProperty($Boolean.prototype, "constructor", $Boolean, DONT_ENUM);
InstallFunctions($Boolean.prototype, DONT_ENUM, $Array(
"toString", BooleanToString,
%OptimizeObjectForAddingMultipleProperties($Number.prototype, 8);
// Set up the constructor property on the Number prototype object.
- %SetProperty($Number.prototype, "constructor", $Number, DONT_ENUM);
+ %AddProperty($Number.prototype, "constructor", $Number, DONT_ENUM);
InstallConstants($Number, $Array(
// ECMA-262 section 15.7.3.1.
%CheckIsBootstrapping();
%SetCode($Function, FunctionConstructor);
- %SetProperty($Function.prototype, "constructor", $Function, DONT_ENUM);
+ %AddProperty($Function.prototype, "constructor", $Function, DONT_ENUM);
InstallFunctions($Function.prototype, DONT_ENUM, $Array(
"bind", FunctionBind,
%SetCode($WeakMap, WeakMapConstructor);
%FunctionSetPrototype($WeakMap, new $Object());
- %SetProperty($WeakMap.prototype, "constructor", $WeakMap, DONT_ENUM);
+ %AddProperty($WeakMap.prototype, "constructor", $WeakMap, DONT_ENUM);
// Set up the non-enumerable functions on the WeakMap prototype object.
InstallFunctions($WeakMap.prototype, DONT_ENUM, $Array(
%SetCode($WeakSet, WeakSetConstructor);
%FunctionSetPrototype($WeakSet, new $Object());
- %SetProperty($WeakSet.prototype, "constructor", $WeakSet, DONT_ENUM);
+ %AddProperty($WeakSet.prototype, "constructor", $WeakSet, DONT_ENUM);
// Set up the non-enumerable functions on the WeakSet prototype object.
InstallFunctions($WeakSet.prototype, DONT_ENUM, $Array(
VisitForStackValue(value);
if (property->emit_store()) {
__ Push(Smi::FromInt(NONE)); // PropertyAttributes
- __ CallRuntime(Runtime::kSetProperty, 4);
+ __ CallRuntime(Runtime::kAddProperty, 4);
} else {
__ Drop(3);
}
EmitAccessor(it->second->getter);
EmitAccessor(it->second->setter);
__ Push(Smi::FromInt(NONE));
- __ CallRuntime(Runtime::kDefineOrRedefineAccessorProperty, 5);
+ __ CallRuntime(Runtime::kDefineAccessorPropertyUnchecked, 5);
}
if (expr->has_function()) {
VisitForStackValue(value);
if (property->emit_store()) {
__ push(Immediate(Smi::FromInt(NONE))); // PropertyAttributes
- __ CallRuntime(Runtime::kSetProperty, 4);
+ __ CallRuntime(Runtime::kAddProperty, 4);
} else {
__ Drop(3);
}
EmitAccessor(it->second->getter);
EmitAccessor(it->second->setter);
__ push(Immediate(Smi::FromInt(NONE)));
- __ CallRuntime(Runtime::kDefineOrRedefineAccessorProperty, 5);
+ __ CallRuntime(Runtime::kDefineAccessorPropertyUnchecked, 5);
}
if (expr->has_function()) {
CheckCorrectThrow("JSON.stringify(other)");
CheckCorrectThrow("has_own_property(other, 'x')");
CheckCorrectThrow("%GetProperty(other, 'x')");
- CheckCorrectThrow("%SetProperty(other, 'x', 'foo', 1, 0)");
- CheckCorrectThrow("%IgnoreAttributesAndSetProperty(other, 'x', 'foo')");
+ CheckCorrectThrow("%SetProperty(other, 'x', 'foo', 0)");
+ CheckCorrectThrow("%AddProperty(other, 'x', 'foo', 1)");
CheckCorrectThrow("%DeleteProperty(other, 'x', 0)");
CheckCorrectThrow("%DeleteProperty(other, '1', 0)");
CheckCorrectThrow("%HasOwnProperty(other, 'x')");
CheckCorrectThrow("%GetPropertyNames(other)");
// PROPERTY_ATTRIBUTES_NONE = 0
CheckCorrectThrow("%GetOwnPropertyNames(other, 0)");
- CheckCorrectThrow("%DefineOrRedefineAccessorProperty("
+ CheckCorrectThrow("%DefineAccessorPropertyUnchecked("
"other, 'x', null, null, 1)");
// Reset the failed access check callback so it does not influence
Handle<String> internalized_name =
isolate->factory()->InternalizeUtf8String(name);
Handle<JSObject> global(isolate->context()->global_object());
- Runtime::SetObjectProperty(isolate, global, internalized_name, object, NONE,
+ Runtime::SetObjectProperty(isolate, global, internalized_name, object,
SLOPPY).Check();
}
v8::Utils::OpenHandle(*context_->Global())));
Handle<v8::internal::String> debug_string =
factory->InternalizeOneByteString(STATIC_ASCII_VECTOR("debug"));
- v8::internal::Runtime::SetObjectProperty(isolate, global, debug_string,
- Handle<Object>(debug_context->global_proxy(), isolate),
- DONT_ENUM,
- ::v8::internal::SLOPPY).Check();
+ v8::internal::Runtime::DefineObjectProperty(global, debug_string,
+ handle(debug_context->global_proxy(), isolate), DONT_ENUM).Check();
}
private:
}
-// Test runtime calls to DefineOrRedefineDataProperty and
-// DefineOrRedefineAccessorProperty - make sure we don't
+// Test runtime calls to DefineDataPropertyUnchecked and
+// DefineAccessorPropertyUnchecked - make sure we don't
// crash.
try {
- %DefineOrRedefineAccessorProperty(0, 0, 0, 0, 0);
+ %DefineAccessorPropertyUnchecked(0, 0, 0, 0, 0);
} catch (e) {
assertTrue(/illegal access/.test(e));
}
try {
- %DefineOrRedefineDataProperty(0, 0, 0, 0);
+ %DefineDataPropertyUnchecked(0, 0, 0, 0);
} catch (e) {
assertTrue(/illegal access/.test(e));
}
try {
- %DefineOrRedefineDataProperty(null, null, null, null);
+ %DefineDataPropertyUnchecked(null, null, null, null);
} catch (e) {
assertTrue(/illegal access/.test(e));
}
try {
- %DefineOrRedefineAccessorProperty(null, null, null, null, null);
+ %DefineAccessorPropertyUnchecked(null, null, null, null, null);
} catch (e) {
assertTrue(/illegal access/.test(e));
}
try {
- %DefineOrRedefineDataProperty({}, null, null, null);
+ %DefineDataPropertyUnchecked({}, null, null, null);
} catch (e) {
assertTrue(/illegal access/.test(e));
}
// Defining properties null should fail even when we have
// other allowed values
try {
- %DefineOrRedefineAccessorProperty(null, 'foo', func, null, 0);
+ %DefineAccessorPropertyUnchecked(null, 'foo', func, null, 0);
} catch (e) {
assertTrue(/illegal access/.test(e));
}
try {
- %DefineOrRedefineDataProperty(null, 'foo', 0, 0);
+ %DefineDataPropertyUnchecked(null, 'foo', 0, 0);
} catch (e) {
assertTrue(/illegal access/.test(e));
}
const READ_ONLY = 1;
// Use DeclareGlobal...
-%SetProperty(this.__proto__, "a", 1234, NONE);
+%AddProperty(this.__proto__, "a", 1234, NONE);
assertEquals(1234, a);
eval("var a = 5678;");
assertEquals(5678, a);
-%SetProperty(this.__proto__, "b", 1234, NONE);
+%AddProperty(this.__proto__, "b", 1234, NONE);
assertEquals(1234, b);
eval("const b = 5678;");
assertEquals(5678, b);
-%SetProperty(this.__proto__, "c", 1234, READ_ONLY);
+%AddProperty(this.__proto__, "c", 1234, READ_ONLY);
assertEquals(1234, c);
eval("var c = 5678;");
assertEquals(5678, c);
-%SetProperty(this.__proto__, "d", 1234, READ_ONLY);
+%AddProperty(this.__proto__, "d", 1234, READ_ONLY);
assertEquals(1234, d);
eval("const d = 5678;");
assertEquals(5678, d);
// Use DeclareContextSlot...
-%SetProperty(this.__proto__, "x", 1234, NONE);
+%AddProperty(this.__proto__, "x", 1234, NONE);
assertEquals(1234, x);
eval("with({}) { var x = 5678; }");
assertEquals(5678, x);
-%SetProperty(this.__proto__, "y", 1234, NONE);
+%AddProperty(this.__proto__, "y", 1234, NONE);
assertEquals(1234, y);
eval("with({}) { const y = 5678; }");
assertEquals(5678, y);
-%SetProperty(this.__proto__, "z", 1234, READ_ONLY);
+%AddProperty(this.__proto__, "z", 1234, READ_ONLY);
assertEquals(1234, z);
eval("with({}) { var z = 5678; }");
assertEquals(5678, z);
-%SetProperty(this.__proto__, "w", 1234, READ_ONLY);
+%AddProperty(this.__proto__, "w", 1234, READ_ONLY);
assertEquals(1234, w);
eval("with({}) { const w = 5678; }");
assertEquals(5678, w);
function func2(){}
var object = {__proto__:{}};
-%SetProperty(object, "foo", func1, DONT_ENUM | DONT_DELETE);
-%SetProperty(object, "bar", func1, DONT_ENUM | READ_ONLY);
-%SetProperty(object, "baz", func1, DONT_DELETE | READ_ONLY);
-%SetProperty(object.__proto__, "bif", func1, DONT_ENUM | DONT_DELETE);
+%AddProperty(object, "foo", func1, DONT_ENUM | DONT_DELETE);
+%AddProperty(object, "bar", func1, DONT_ENUM | READ_ONLY);
+%AddProperty(object, "baz", func1, DONT_DELETE | READ_ONLY);
+%AddProperty(object.__proto__, "bif", func1, DONT_ENUM | DONT_DELETE);
object.bif = func2;
function enumerable(obj) {
DontEnum = 2;
var o = {};
-%SetProperty(o, "a", 0, DontEnum);
+%AddProperty(o, "a", 0, DontEnum);
var o2 = {};
-%SetProperty(o2, "a", 0, DontEnum);
+%AddProperty(o2, "a", 0, DontEnum);
assertTrue(%HaveSameMap(o, o2));
// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY
// Flags: --allow-natives-syntax --harmony
var _object = new Object();
-var _name = "name";
+var arg1 = 10;
var _value = new Object();
-var _unchecked_value = 1;
-%IgnoreAttributesAndSetProperty(_object, _name, _value, _unchecked_value);
+var _unchecked_attributes = 1;
+%AddProperty(_object, arg1, _value, _unchecked_attributes);
var arg2 = function() {};
var arg3 = function() {};
var arg4 = 2;
-%DefineOrRedefineAccessorProperty(_obj, _name, arg2, arg3, arg4);
+%DefineAccessorPropertyUnchecked(_obj, _name, arg2, arg3, arg4);
var _name = "name";
var _obj_value = new Object();
var _unchecked = 1;
-%DefineOrRedefineDataProperty(_js_object, _name, _obj_value, _unchecked);
+%DefineDataPropertyUnchecked(_js_object, _name, _obj_value, _unchecked);
+++ /dev/null
-// Copyright 2014 the V8 project authors. All rights reserved.
-// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY
-// Flags: --allow-natives-syntax --harmony
-var _object = new Object();
-var _name = "name";
-var arg2 = undefined;
-var arg3 = undefined;
-var _attribute = 1;
-%SetAccessorProperty(_object, _name, arg2, arg3, _attribute);
var _object = new Object();
var _key = new Object();
var _value = new Object();
-var _unchecked_attributes = 1;
var _strict_mode_arg = 1;
-%SetProperty(_object, _key, _value, _unchecked_attributes, _strict_mode_arg);
+%SetProperty(_object, _key, _value, _strict_mode_arg);
# that the parser doesn't bit-rot. Change the values as needed when you add,
# remove or change runtime functions, but make sure we don't lose our ability
# to parse them!
-EXPECTED_FUNCTION_COUNT = 415
-EXPECTED_FUZZABLE_COUNT = 330
+EXPECTED_FUNCTION_COUNT = 414
+EXPECTED_FUZZABLE_COUNT = 329
EXPECTED_CCTEST_COUNT = 6
EXPECTED_UNKNOWN_COUNT = 4
EXPECTED_BUILTINS_COUNT = 806
# Format: "FunctionName": ["arg0", "arg1", ..., argslength].
# None means "fall back to autodetected value".
CUSTOM_KNOWN_GOOD_INPUT = {
+ "AddProperty": [None, 10, None, None, None],
"Apply": ["function() {}", None, None, None, None, None],
"ArrayBufferSliceImpl": [None, None, 0, None],
"ArrayConcat": ["[1, 'a']", None],
"CreatePrivateSymbol": ["\"foo\"", None],
"CreateSymbol": ["\"foo\"", None],
"DateParseString": [None, "new Array(8)", None],
- "DefineOrRedefineAccessorProperty": [None, None, "function() {}",
- "function() {}", 2, None],
+ "DefineAccessorPropertyUnchecked": [None, None, "function() {}",
+ "function() {}", 2, None],
"FunctionBindArguments": [None, None, "undefined", None, None],
"GetBreakLocations": [None, 0, None],
"GetDefaultReceiver": ["function() {}", None],
"NumberToRadixString": [None, "2", None],
"ParseJson": ["\"{}\"", 1],
"RegExpExecMultiple": [None, None, "['a']", "['a']", None],
- "SetAccessorProperty": [None, None, "undefined", "undefined", None, None],
+ "DefineAccessorProperty": [None, None, "undefined", "undefined", None, None],
"SetIteratorInitialize": [None, None, "2", None],
"SetDebugEventListener": ["undefined", None, None],
"SetFunctionBreakPoint": [None, 200, None, None],