Commit 723cd988 authored by rossberg@chromium.org's avatar rossberg@chromium.org

Fix set-up of intrinsic's 'constructor' properties

Looks so easy...

R=mstarzinger@chromium.org
BUG=229445

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14229 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 6a260c33
......@@ -874,14 +874,7 @@ Handle<JSFunction> Factory::NewFunctionWithPrototype(Handle<String> name,
initial_map->set_constructor(*function);
}
// Set function.prototype and give the prototype a constructor
// property that refers to the function.
SetPrototypeProperty(function, prototype);
// Currently safe because it is only invoked from Genesis.
CHECK_NOT_EMPTY_HANDLE(isolate(),
JSObject::SetLocalPropertyIgnoreAttributes(
prototype, constructor_string(),
function, DONT_ENUM));
return function;
}
......
......@@ -1356,12 +1356,13 @@ function ObjectConstructor(x) {
function SetUpObject() {
%CheckIsBootstrapping();
$Object.prototype.constructor = $Object;
%SetCode($Object, ObjectConstructor);
%FunctionSetName(ObjectPoisonProto, "__proto__");
%FunctionRemovePrototype(ObjectPoisonProto);
%SetExpectedNumberOfProperties($Object, 4);
%SetProperty($Object.prototype, "constructor", $Object, DONT_ENUM);
// Set up non-enumerable functions on the Object.prototype object.
InstallFunctions($Object.prototype, DONT_ENUM, $Array(
"toString", ObjectToString,
......@@ -1788,8 +1789,8 @@ function NewFunction(arg1) { // length == 1
function SetUpFunction() {
%CheckIsBootstrapping();
$Function.prototype.constructor = $Function;
%SetCode($Function, NewFunction);
%SetProperty($Function.prototype, "constructor", $Function, DONT_ENUM);
InstallFunctions($Function.prototype, DONT_ENUM, $Array(
"bind", FunctionBind,
......
......@@ -82,6 +82,23 @@ function TestPrototype() {
TestPrototype()
function TestConstructor() {
assertFalse(Object === Symbol.prototype.constructor)
assertFalse(Symbol === Object.prototype.constructor)
assertSame(Symbol, Symbol.prototype.constructor)
assertSame(Symbol, Symbol().__proto__.constructor)
assertSame(Symbol, Symbol(Symbol()).__proto__.constructor)
assertSame(Symbol, (new Symbol).__proto__.constructor)
assertSame(Symbol, (new Symbol()).__proto__.constructor)
assertSame(Symbol, (new Symbol(Symbol())).__proto__.constructor)
assertSame(Symbol, Object(Symbol()).__proto__.constructor)
for (var i in symbols) {
assertSame(Symbol, symbols[i].__proto__.constructor)
}
}
TestConstructor()
function TestName() {
for (var i in symbols) {
var name = symbols[i].name
......
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