V(SAR_STRONG, 1) \
V(SHR, 1) \
V(SHR_STRONG, 1) \
- V(DELETE, 2) \
V(IN, 1) \
V(INSTANCE_OF, 1) \
V(CALL_NON_FUNCTION, 0) \
void JSGenericLowering::LowerJSDeleteProperty(Node* node) {
LanguageMode language_mode = OpParameter<LanguageMode>(node);
- ReplaceWithBuiltinCall(node, Builtins::DELETE, 3);
- node->InsertInput(zone(), 4, jsgraph()->SmiConstant(language_mode));
+ ReplaceWithRuntimeCall(node, is_strict(language_mode)
+ ? Runtime::kDeleteProperty_Strict
+ : Runtime::kDeleteProperty_Sloppy);
}
if (property != NULL) {
VisitForStackValue(property->obj());
VisitForStackValue(property->key());
- __ mov(r1, Operand(Smi::FromInt(language_mode())));
- __ push(r1);
- __ InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION);
+ __ CallRuntime(is_strict(language_mode())
+ ? Runtime::kDeleteProperty_Strict
+ : Runtime::kDeleteProperty_Sloppy,
+ 2);
context()->Plug(r0);
} else if (proxy != NULL) {
Variable* var = proxy->var();
if (var->IsUnallocatedOrGlobalSlot()) {
__ ldr(r2, GlobalObjectOperand());
__ mov(r1, Operand(var->name()));
- __ mov(r0, Operand(Smi::FromInt(SLOPPY)));
- __ Push(r2, r1, r0);
- __ InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION);
+ __ Push(r2, r1);
+ __ CallRuntime(Runtime::kDeleteProperty_Sloppy, 2);
context()->Plug(r0);
} else if (var->IsStackAllocated() || var->IsContextSlot()) {
// Result of deleting non-global, non-dynamic variables is false.
if (property != NULL) {
VisitForStackValue(property->obj());
VisitForStackValue(property->key());
- __ Mov(x10, Smi::FromInt(language_mode()));
- __ Push(x10);
- __ InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION);
+ __ CallRuntime(is_strict(language_mode())
+ ? Runtime::kDeleteProperty_Strict
+ : Runtime::kDeleteProperty_Sloppy,
+ 2);
context()->Plug(x0);
} else if (proxy != NULL) {
Variable* var = proxy->var();
if (var->IsUnallocatedOrGlobalSlot()) {
__ Ldr(x12, GlobalObjectMemOperand());
__ Mov(x11, Operand(var->name()));
- __ Mov(x10, Smi::FromInt(SLOPPY));
- __ Push(x12, x11, x10);
- __ InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION);
+ __ Push(x12, x11);
+ __ CallRuntime(Runtime::kDeleteProperty_Sloppy, 2);
context()->Plug(x0);
} else if (var->IsStackAllocated() || var->IsContextSlot()) {
// Result of deleting non-global, non-dynamic variables is false.
if (property != NULL) {
VisitForStackValue(property->obj());
VisitForStackValue(property->key());
- __ push(Immediate(Smi::FromInt(language_mode())));
- __ InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION);
+ __ CallRuntime(is_strict(language_mode())
+ ? Runtime::kDeleteProperty_Strict
+ : Runtime::kDeleteProperty_Sloppy,
+ 2);
context()->Plug(eax);
} else if (proxy != NULL) {
Variable* var = proxy->var();
if (var->IsUnallocatedOrGlobalSlot()) {
__ push(GlobalObjectOperand());
__ push(Immediate(var->name()));
- __ push(Immediate(Smi::FromInt(SLOPPY)));
- __ InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION);
+ __ CallRuntime(Runtime::kDeleteProperty_Sloppy, 2);
context()->Plug(eax);
} else if (var->IsStackAllocated() || var->IsContextSlot()) {
// Result of deleting non-global variables is false. 'this' is
if (property != NULL) {
VisitForStackValue(property->obj());
VisitForStackValue(property->key());
- __ li(a1, Operand(Smi::FromInt(language_mode())));
- __ push(a1);
- __ InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION);
+ __ CallRuntime(is_strict(language_mode())
+ ? Runtime::kDeleteProperty_Strict
+ : Runtime::kDeleteProperty_Sloppy,
+ 2);
context()->Plug(v0);
} else if (proxy != NULL) {
Variable* var = proxy->var();
if (var->IsUnallocatedOrGlobalSlot()) {
__ lw(a2, GlobalObjectOperand());
__ li(a1, Operand(var->name()));
- __ li(a0, Operand(Smi::FromInt(SLOPPY)));
- __ Push(a2, a1, a0);
- __ InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION);
+ __ Push(a2, a1);
+ __ CallRuntime(Runtime::kDeleteProperty_Sloppy, 2);
context()->Plug(v0);
} else if (var->IsStackAllocated() || var->IsContextSlot()) {
// Result of deleting non-global, non-dynamic variables is false.
if (property != NULL) {
VisitForStackValue(property->obj());
VisitForStackValue(property->key());
- __ li(a1, Operand(Smi::FromInt(language_mode())));
- __ push(a1);
- __ InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION);
+ __ CallRuntime(is_strict(language_mode())
+ ? Runtime::kDeleteProperty_Strict
+ : Runtime::kDeleteProperty_Sloppy,
+ 2);
context()->Plug(v0);
} else if (proxy != NULL) {
Variable* var = proxy->var();
if (var->IsUnallocatedOrGlobalSlot()) {
__ ld(a2, GlobalObjectOperand());
__ li(a1, Operand(var->name()));
- __ li(a0, Operand(Smi::FromInt(SLOPPY)));
- __ Push(a2, a1, a0);
- __ InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION);
+ __ Push(a2, a1);
+ __ CallRuntime(Runtime::kDeleteProperty_Sloppy, 2);
context()->Plug(v0);
} else if (var->IsStackAllocated() || var->IsContextSlot()) {
// Result of deleting non-global, non-dynamic variables is false.
if (property != NULL) {
VisitForStackValue(property->obj());
VisitForStackValue(property->key());
- __ LoadSmiLiteral(r4, Smi::FromInt(language_mode()));
- __ push(r4);
- __ InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION);
+ __ CallRuntime(is_strict(language_mode())
+ ? Runtime::kDeleteProperty_Strict
+ : Runtime::kDeleteProperty_Sloppy,
+ 2);
context()->Plug(r3);
} else if (proxy != NULL) {
Variable* var = proxy->var();
if (var->IsUnallocatedOrGlobalSlot()) {
__ LoadP(r5, GlobalObjectOperand());
__ mov(r4, Operand(var->name()));
- __ LoadSmiLiteral(r3, Smi::FromInt(SLOPPY));
- __ Push(r5, r4, r3);
- __ InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION);
+ __ Push(r5, r4);
+ __ CallRuntime(Runtime::kDeleteProperty_Sloppy, 2);
context()->Plug(r3);
} else if (var->IsStackAllocated() || var->IsContextSlot()) {
// Result of deleting non-global, non-dynamic variables is false.
if (property != NULL) {
VisitForStackValue(property->obj());
VisitForStackValue(property->key());
- __ Push(Smi::FromInt(language_mode()));
- __ InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION);
+ __ CallRuntime(is_strict(language_mode())
+ ? Runtime::kDeleteProperty_Strict
+ : Runtime::kDeleteProperty_Sloppy,
+ 2);
context()->Plug(rax);
} else if (proxy != NULL) {
Variable* var = proxy->var();
if (var->IsUnallocatedOrGlobalSlot()) {
__ Push(GlobalObjectOperand());
__ Push(var->name());
- __ Push(Smi::FromInt(SLOPPY));
- __ InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION);
+ __ CallRuntime(Runtime::kDeleteProperty_Sloppy, 2);
context()->Plug(rax);
} else if (var->IsStackAllocated() || var->IsContextSlot()) {
// Result of deleting non-global variables is false. 'this' is
if (property != NULL) {
VisitForStackValue(property->obj());
VisitForStackValue(property->key());
- __ push(Immediate(Smi::FromInt(language_mode())));
- __ InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION);
+ __ CallRuntime(is_strict(language_mode())
+ ? Runtime::kDeleteProperty_Strict
+ : Runtime::kDeleteProperty_Sloppy,
+ 2);
context()->Plug(eax);
} else if (proxy != NULL) {
Variable* var = proxy->var();
if (var->IsUnallocatedOrGlobalSlot()) {
__ push(GlobalObjectOperand());
__ push(Immediate(var->name()));
- __ push(Immediate(Smi::FromInt(SLOPPY)));
- __ InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION);
+ __ CallRuntime(Runtime::kDeleteProperty_Sloppy, 2);
context()->Plug(eax);
} else if (var->IsStackAllocated() || var->IsContextSlot()) {
// Result of deleting non-global variables is false. 'this' is
CHECK_ALIVE(VisitForValue(prop->key()));
HValue* key = Pop();
HValue* obj = Pop();
- HValue* function = AddLoadJSBuiltin(Builtins::DELETE);
- Add<HPushArguments>(obj, key, Add<HConstant>(function_language_mode()));
- // TODO(olivf) InvokeFunction produces a check for the parameter count,
- // even though we are certain to pass the correct number of arguments here.
- HInstruction* instr = New<HInvokeFunction>(function, 3);
+ Add<HPushArguments>(obj, key);
+ HInstruction* instr = New<HCallRuntime>(
+ isolate()->factory()->empty_string(),
+ Runtime::FunctionForId(is_strict(function_language_mode())
+ ? Runtime::kDeleteProperty_Strict
+ : Runtime::kDeleteProperty_Sloppy),
+ 2);
return ast_context()->ReturnInstruction(instr, expr->id());
} else if (proxy != NULL) {
Variable* var = proxy->var();
var SAR_STRONG;
var SHR;
var SHR_STRONG;
-var DELETE;
var IN;
var INSTANCE_OF;
var CALL_NON_FUNCTION;
-----------------------------
*/
-// ECMA-262, section 11.4.1, page 46.
-DELETE = function DELETE(key, language_mode) {
- return %DeleteProperty(TO_OBJECT(this), key, language_mode);
-}
-
-
// ECMA-262, section 11.8.7, page 54.
IN = function IN(x) {
if (!IS_SPEC_OBJECT(x)) {
}
-RUNTIME_FUNCTION(Runtime_DeleteProperty) {
- HandleScope scope(isolate);
- DCHECK(args.length() == 3);
- CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0);
- CONVERT_ARG_HANDLE_CHECKED(Object, key, 1);
- CONVERT_LANGUAGE_MODE_ARG_CHECKED(language_mode, 2);
+namespace {
+
+// ES6 section 12.5.4.
+Object* DeleteProperty(Isolate* isolate, Handle<Object> object,
+ Handle<Object> key, LanguageMode language_mode) {
+ Handle<JSReceiver> receiver;
+ if (!JSReceiver::ToObject(isolate, object).ToHandle(&receiver)) {
+ THROW_NEW_ERROR_RETURN_FAILURE(
+ isolate, NewTypeError(MessageTemplate::kUndefinedOrNullToObject));
+ }
Handle<Object> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, result,
return *result;
}
+} // namespace
+
+
+RUNTIME_FUNCTION(Runtime_DeleteProperty_Sloppy) {
+ HandleScope scope(isolate);
+ DCHECK_EQ(2, args.length());
+ CONVERT_ARG_HANDLE_CHECKED(Object, object, 0);
+ CONVERT_ARG_HANDLE_CHECKED(Object, key, 1);
+ return DeleteProperty(isolate, object, key, SLOPPY);
+}
+
+
+RUNTIME_FUNCTION(Runtime_DeleteProperty_Strict) {
+ HandleScope scope(isolate);
+ DCHECK_EQ(2, args.length());
+ CONVERT_ARG_HANDLE_CHECKED(Object, object, 0);
+ CONVERT_ARG_HANDLE_CHECKED(Object, key, 1);
+ return DeleteProperty(isolate, object, key, STRICT);
+}
+
static Object* HasOwnPropertyImplementation(Isolate* isolate,
Handle<JSObject> object,
F(SetProperty, 4, 1) \
F(AddElement, 3, 1) \
F(AppendElement, 2, 1) \
- F(DeleteProperty, 3, 1) \
+ F(DeleteProperty_Sloppy, 2, 1) \
+ F(DeleteProperty_Strict, 2, 1) \
F(HasOwnProperty, 2, 1) \
F(HasProperty, 2, 1) \
F(HasElement, 2, 1) \
var desc = GetOwnPropertyJS(obj, p);
if (IS_UNDEFINED(desc)) return true;
if (desc.isConfigurable()) {
- %DeleteProperty(obj, p, 0);
+ %DeleteProperty_Sloppy(obj, p);
return true;
} else if (should_throw) {
throw MakeTypeError(kDefineDisallowed, p);
CheckCorrectThrow("%GetProperty(other, 'x')");
CheckCorrectThrow("%SetProperty(other, 'x', 'foo', 0)");
CheckCorrectThrow("%AddNamedProperty(other, 'x', 'foo', 1)");
- CheckCorrectThrow("%DeleteProperty(other, 'x', 0)");
- CheckCorrectThrow("%DeleteProperty(other, '1', 0)");
+ CheckCorrectThrow("%DeleteProperty_Sloppy(other, 'x')");
+ CheckCorrectThrow("%DeleteProperty_Strict(other, 'x')");
+ CheckCorrectThrow("%DeleteProperty_Sloppy(other, '1')");
+ CheckCorrectThrow("%DeleteProperty_Strict(other, '1')");
CheckCorrectThrow("%HasOwnProperty(other, 'x')");
CheckCorrectThrow("%HasProperty(other, 'x')");
CheckCorrectThrow("%HasElement(other, 1)");