Skip to content

Commit

Permalink
Revert of Revert of [es6] don't throw if argument is non-object (O.fr…
Browse files Browse the repository at this point in the history
…eeze, O.seal, O.preventExtensions) (patchset #1 id:1 of https://codereview.chromium.org/1103473003/)

Reason for revert:
This was probably an infrastructure problem caused by the mac ninja/goma switch.

Original issue's description:
> Revert of [es6] don't throw if argument is non-object (O.freeze, O.seal, O.preventExtensions) (patchset #7 id:140001 of https://codereview.chromium.org/1011823003/)
>
> Reason for revert:
> [Sheriff] breaks mac gc stress:
> http://build.chromium.org/p/client.v8/builders/V8%20Mac%20GC%20Stress/builds/1029
>
> Original issue's description:
> > [es6] don't throw if argument is non-object (O.freeze, O.seal, O.preventExtensions)
> >
> > BUG=v8:3965, v8:3966
> > R=arv@chromium.org
> > LOG=N
> >
> > Committed: https://crrev.com/b09c048f693d280052ac63c7d6b3baf27b3bf271
> > Cr-Commit-Position: refs/heads/master@{#27985}
>
> TBR=arv@chromium.org,caitpotter88@gmail.com
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=v8:3965, v8:3966

TBR=arv@chromium.org,caitpotter88@gmail.com
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=v8:3965, v8:3966

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

Cr-Commit-Position: refs/heads/master@{#27999}
  • Loading branch information
mi-ac authored and Commit bot committed Apr 22, 2015
1 parent 15b98a3 commit 6911943
Show file tree
Hide file tree
Showing 6 changed files with 117 additions and 89 deletions.
24 changes: 6 additions & 18 deletions src/v8natives.js
Original file line number Diff line number Diff line change
Expand Up @@ -1255,9 +1255,7 @@ function ProxyFix(obj) {

// ES5 section 15.2.3.8.
function ObjectSealJS(obj) {
if (!IS_SPEC_OBJECT(obj)) {
throw MakeTypeError(kCalledOnNonObject, "Object.seal");
}
if (!IS_SPEC_OBJECT(obj)) return obj;
var isProxy = %_IsJSProxy(obj);
if (isProxy || %HasSloppyArgumentsElements(obj) || %IsObserved(obj)) {
if (isProxy) {
Expand All @@ -1284,9 +1282,7 @@ function ObjectSealJS(obj) {

// ES5 section 15.2.3.9.
function ObjectFreezeJS(obj) {
if (!IS_SPEC_OBJECT(obj)) {
throw MakeTypeError(kCalledOnNonObject, "Object.freeze");
}
if (!IS_SPEC_OBJECT(obj)) return obj;
var isProxy = %_IsJSProxy(obj);
if (isProxy || %HasSloppyArgumentsElements(obj) || %IsObserved(obj)) {
if (isProxy) {
Expand Down Expand Up @@ -1314,9 +1310,7 @@ function ObjectFreezeJS(obj) {

// ES5 section 15.2.3.10
function ObjectPreventExtension(obj) {
if (!IS_SPEC_OBJECT(obj)) {
throw MakeTypeError(kCalledOnNonObject, "Object.preventExtension");
}
if (!IS_SPEC_OBJECT(obj)) return obj;
if (%_IsJSProxy(obj)) {
ProxyFix(obj);
}
Expand All @@ -1327,9 +1321,7 @@ function ObjectPreventExtension(obj) {

// ES5 section 15.2.3.11
function ObjectIsSealed(obj) {
if (!IS_SPEC_OBJECT(obj)) {
throw MakeTypeError(kCalledOnNonObject, "Object.isSealed");
}
if (!IS_SPEC_OBJECT(obj)) return true;
if (%_IsJSProxy(obj)) {
return false;
}
Expand All @@ -1350,9 +1342,7 @@ function ObjectIsSealed(obj) {

// ES5 section 15.2.3.12
function ObjectIsFrozen(obj) {
if (!IS_SPEC_OBJECT(obj)) {
throw MakeTypeError(kCalledOnNonObject, "Object.isFrozen");
}
if (!IS_SPEC_OBJECT(obj)) return true;
if (%_IsJSProxy(obj)) {
return false;
}
Expand All @@ -1372,9 +1362,7 @@ function ObjectIsFrozen(obj) {

// ES5 section 15.2.3.13
function ObjectIsExtensible(obj) {
if (!IS_SPEC_OBJECT(obj)) {
throw MakeTypeError(kCalledOnNonObject, "Object.isExtensible");
}
if (!IS_SPEC_OBJECT(obj)) return false;
if (%_IsJSProxy(obj)) {
return true;
}
Expand Down
5 changes: 0 additions & 5 deletions test/mjsunit/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ test(function() {
[].forEach(1);
}, "1 is not a function", TypeError);

// kCalledOnNonObject
test(function() {
Object.freeze(1)
}, "Object.freeze called on non-object", TypeError);

// kCannotConvertToPrimitive
test(function() {
[].join(Object(Symbol(1)));
Expand Down
88 changes: 68 additions & 20 deletions test/mjsunit/object-freeze.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,33 +25,20 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

// Tests the Object.freeze and Object.isFrozen methods - ES 15.2.3.9 and
// ES 15.2.3.12
// Tests the Object.freeze and Object.isFrozen methods - ES 19.1.2.5 and
// ES 19.1.2.12

// Flags: --allow-natives-syntax

// Test that we throw an error if an object is not passed as argument.
var non_objects = new Array(undefined, null, 1, -1, 0, 42.43);
// Test that we return obj if non-object is passed as argument
var non_objects = new Array(undefined, null, 1, -1, 0, 42.43, Symbol("test"));
for (var key in non_objects) {
var exception = false;
try {
Object.freeze(non_objects[key]);
} catch(e) {
exception = true;
assertTrue(/Object.freeze called on non-object/.test(e));
}
assertTrue(exception);
assertSame(non_objects[key], Object.freeze(non_objects[key]));
}

// Test that isFrozen always returns true for non-objects
for (var key in non_objects) {
exception = false;
try {
Object.isFrozen(non_objects[key]);
} catch(e) {
exception = true;
assertTrue(/Object.isFrozen called on non-object/.test(e));
}
assertTrue(exception);
assertTrue(Object.isFrozen(non_objects[key]));
}

// Test normal data properties.
Expand Down Expand Up @@ -348,3 +335,64 @@ assertFalse(Object.isFrozen(obj));
Object.freeze(obj);
assertTrue(Object.isSealed(obj));
assertTrue(Object.isFrozen(obj));


(function propertiesOfFrozenObjectNotFrozen() {
function Frozen() {}
Object.freeze(Frozen);
assertDoesNotThrow(function() { return new Frozen(); });
Frozen.prototype.prototypeExists = true;
assertTrue((new Frozen()).prototypeExists);
})();


(function frozenPrototypePreventsPUT() {
// A read-only property on the prototype should prevent a [[Put]] .
function Constructor() {}
Constructor.prototype.foo = 1;
Object.freeze(Constructor.prototype);
var obj = new Constructor();
obj.foo = 2;
assertSame(1, obj.foo);
})();


(function frozenFunctionSloppy() {
// Check that freezing a function works correctly.
var func = Object.freeze(function foo(){});
assertTrue(Object.isFrozen(func));
func.prototype = 42;
assertFalse(func.prototype === 42);
assertFalse(Object.getOwnPropertyDescriptor(func, "prototype").writable);
})();


(function frozenFunctionStrict() {
// Check that freezing a strict function works correctly.
var func = Object.freeze(function foo(){ "use strict"; });
assertTrue(Object.isFrozen(func));
func.prototype = 42;
assertFalse(func.prototype === 42);
assertFalse(Object.getOwnPropertyDescriptor(func, "prototype").writable);
})();


(function frozenArrayObject() {
// Check that freezing array objects works correctly.
var array = Object.freeze([0,1,2]);
assertTrue(Object.isFrozen(array));
array[0] = 3;
assertEquals(0, array[0]);
assertFalse(Object.getOwnPropertyDescriptor(array, "length").writable);
})();


(function frozenArgumentsObject() {
// Check that freezing arguments objects works correctly.
var args = Object.freeze((function(){ return arguments; })(0,1,2));
assertTrue(Object.isFrozen(args));
args[0] = 3;
assertEquals(0, args[0]);
assertFalse(Object.getOwnPropertyDescriptor(args, "length").writable);
assertFalse(Object.getOwnPropertyDescriptor(args, "callee").writable);
})();
33 changes: 13 additions & 20 deletions test/mjsunit/object-seal.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,33 +25,20 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

// Tests the Object.seal and Object.isSealed methods - ES 15.2.3.9 and
// ES 15.2.3.12
// Tests the Object.seal and Object.isSealed methods - ES 19.1.2.17 and
// ES 19.1.2.13

// Flags: --allow-natives-syntax --noalways-opt

// Test that we throw an error if an object is not passed as argument.
var non_objects = new Array(undefined, null, 1, -1, 0, 42.43);
// Test that we return obj if non-object is passed as argument
var non_objects = new Array(undefined, null, 1, -1, 0, 42.43, Symbol("test"));
for (var key in non_objects) {
var exception = false;
try {
Object.seal(non_objects[key]);
} catch(e) {
exception = true;
assertTrue(/Object.seal called on non-object/.test(e));
}
assertTrue(exception);
assertSame(non_objects[key], Object.seal(non_objects[key]));
}

// Test that isFrozen always returns true for non-objects
for (var key in non_objects) {
exception = false;
try {
Object.isSealed(non_objects[key]);
} catch(e) {
exception = true;
assertTrue(/Object.isSealed called on non-object/.test(e));
}
assertTrue(exception);
assertTrue(Object.isSealed(non_objects[key]));
}

// Test normal data properties.
Expand Down Expand Up @@ -396,3 +383,9 @@ assertTrue(%HasFastProperties(obj));
Object.seal(obj);
assertTrue(%HasFastProperties(obj));
assertTrue(Object.isSealed(obj));

function Sealed() {}
Object.seal(Sealed);
assertDoesNotThrow(function() { return new Sealed(); });
Sealed.prototype.prototypeExists = true;
assertTrue((new Sealed()).prototypeExists);
26 changes: 0 additions & 26 deletions test/test262-es6/test262-es6.status
Original file line number Diff line number Diff line change
Expand Up @@ -260,36 +260,10 @@
'built-ins/Date/prototype/setFullYear/15.9.5.40_1': [FAIL],
'built-ins/Error/prototype/S15.11.4_A2': [FAIL],
'built-ins/Object/defineProperty/15.2.3.6-4-293-4': [FAIL],
'built-ins/Object/freeze/15.2.3.9-1': [FAIL],
'built-ins/Object/freeze/15.2.3.9-1-1': [FAIL],
'built-ins/Object/freeze/15.2.3.9-1-2': [FAIL],
'built-ins/Object/freeze/15.2.3.9-1-3': [FAIL],
'built-ins/Object/freeze/15.2.3.9-1-4': [FAIL],
'built-ins/Object/getOwnPropertyDescriptor/15.2.3.3-4-212': [FAIL],
'built-ins/Object/getOwnPropertyDescriptor/15.2.3.3-4-213': [FAIL],
'built-ins/Object/getOwnPropertyDescriptor/15.2.3.3-4-214': [FAIL],
'built-ins/Object/getOwnPropertyDescriptor/15.2.3.3-4-215': [FAIL],
'built-ins/Object/isExtensible/15.2.3.13-1': [FAIL],
'built-ins/Object/isExtensible/15.2.3.13-1-1': [FAIL],
'built-ins/Object/isExtensible/15.2.3.13-1-2': [FAIL],
'built-ins/Object/isExtensible/15.2.3.13-1-3': [FAIL],
'built-ins/Object/isExtensible/15.2.3.13-1-4': [FAIL],
'built-ins/Object/isFrozen/15.2.3.12-1': [FAIL],
'built-ins/Object/isFrozen/15.2.3.12-1-1': [FAIL],
'built-ins/Object/isFrozen/15.2.3.12-1-2': [FAIL],
'built-ins/Object/isFrozen/15.2.3.12-1-3': [FAIL],
'built-ins/Object/isFrozen/15.2.3.12-1-4': [FAIL],
'built-ins/Object/isSealed/15.2.3.11-1': [FAIL],
'built-ins/Object/preventExtensions/15.2.3.10-1': [FAIL],
'built-ins/Object/preventExtensions/15.2.3.10-1-1': [FAIL],
'built-ins/Object/preventExtensions/15.2.3.10-1-2': [FAIL],
'built-ins/Object/preventExtensions/15.2.3.10-1-3': [FAIL],
'built-ins/Object/preventExtensions/15.2.3.10-1-4': [FAIL],
'built-ins/Object/seal/15.2.3.8-1': [FAIL],
'built-ins/Object/seal/15.2.3.8-1-1': [FAIL],
'built-ins/Object/seal/15.2.3.8-1-2': [FAIL],
'built-ins/Object/seal/15.2.3.8-1-3': [FAIL],
'built-ins/Object/seal/15.2.3.8-1-4': [FAIL],
'built-ins/Promise/S25.4.3.1_A5.1_T2': [FAIL],
'built-ins/Promise/prototype/then/S25.4.2.1_A3.1_T2': [FAIL],
'built-ins/Promise/prototype/then/S25.4.2.1_A3.2_T2': [FAIL],
Expand Down
30 changes: 30 additions & 0 deletions test/test262/test262.status
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,36 @@
'15.3.4.5-21-4': [FAIL],
'15.3.4.5-21-5': [FAIL],

# Object.freeze(O), Object.seal(O), and Object.preventExtensions(O),
# Object.isFrozen(O), Object.isSealed(O), and Object.isExtensible(O) no longer
# throw when passed a non-object value in ES6.
'15.2.3.8-1': [FAIL],
'15.2.3.8-1-1': [FAIL],
'15.2.3.8-1-2': [FAIL],
'15.2.3.8-1-3': [FAIL],
'15.2.3.8-1-4': [FAIL],
'15.2.3.9-1': [FAIL],
'15.2.3.9-1-1': [FAIL],
'15.2.3.9-1-2': [FAIL],
'15.2.3.9-1-3': [FAIL],
'15.2.3.9-1-4': [FAIL],
'15.2.3.10-1': [FAIL],
'15.2.3.10-1-1': [FAIL],
'15.2.3.10-1-2': [FAIL],
'15.2.3.10-1-3': [FAIL],
'15.2.3.10-1-4': [FAIL],
'15.2.3.11-1': [FAIL],
'15.2.3.12-1': [FAIL],
'15.2.3.12-1-1': [FAIL],
'15.2.3.12-1-2': [FAIL],
'15.2.3.12-1-3': [FAIL],
'15.2.3.12-1-4': [FAIL],
'15.2.3.13-1': [FAIL],
'15.2.3.13-1-1': [FAIL],
'15.2.3.13-1-2': [FAIL],
'15.2.3.13-1-3': [FAIL],
'15.2.3.13-1-4': [FAIL],

######################## NEEDS INVESTIGATION ###########################

# These test failures are specific to the intl402 suite and need investigation
Expand Down

0 comments on commit 6911943

Please sign in to comment.