Reviewers: Kevin Millikin, Erik Corry,
Message:
Added new patch set.
http://codereview.chromium.org/7624041/diff/1/src/bootstrapper.cc
File src/bootstrapper.cc (right):
http://codereview.chromium.org/7624041/diff/1/src/bootstrapper.cc#newcode1163
src/bootstrapper.cc:1163: // Setup the call-as-function delegate.
On 2011/08/30 09:13:01, Erik Corry wrote:
"Setup" is a noun and "Set up" is a verb. And one other place in this
file.
Done.
http://codereview.chromium.org/7624041/diff/1/src/weakmap.js
File src/weakmap.js (right):
http://codereview.chromium.org/7624041/diff/1/src/weakmap.js#newcode90
src/weakmap.js:90: // Setup the constructor property on the WeakMap
prototype object.
On 2011/08/30 09:13:01, Erik Corry wrote:
Setup -> Set up
And 3 other places in this file.
Done.
Description:
Fix initial prototype of WeakMap function.
The bootstrapper accidentally overwrote the constructor property of the
Object
prototype because it used initial_object_prototype() as prototype for
WeakMap.
Unfortunately this is not possible for experimental natives because they are
installed after the snapshot initialization finished.
[email protected]
TEST=mjsunit/mirror-object,mjsunit/harmony/weakmaps
Please review this at http://codereview.chromium.org/7624041/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/bootstrapper.cc
M src/weakmap.js
M test/mjsunit/harmony/weakmaps.js
Index: src/bootstrapper.cc
diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc
index
4f7cf409404e9e909aaa0bde8d36fd3b139acccf..9f01664da126a448d0dce9687f73eec6450d727e
100644
--- a/src/bootstrapper.cc
+++ b/src/bootstrapper.cc
@@ -1160,7 +1160,7 @@ void Genesis::InitializeGlobal(Handle<GlobalObject>
inner_global,
{
- // Setup the call-as-function delegate.
+ // Set up the call-as-function delegate.
Handle<Code> code =
Handle<Code>(isolate->builtins()->builtin(
Builtins::kHandleApiCallAsFunction));
@@ -1172,7 +1172,7 @@ void Genesis::InitializeGlobal(Handle<GlobalObject>
inner_global,
}
{
- // Setup the call-as-constructor delegate.
+ // Set up the call-as-constructor delegate.
Handle<Code> code =
Handle<Code>(isolate->builtins()->builtin(
Builtins::kHandleApiCallAsConstructor));
@@ -1192,15 +1192,15 @@ void Genesis::InitializeGlobal(Handle<GlobalObject>
inner_global,
void Genesis::InitializeExperimentalGlobal() {
- Isolate* isolate = this->isolate();
Handle<JSObject> global = Handle<JSObject>(global_context()->global());
// TODO(mstarzinger): Move this into Genesis::InitializeGlobal once we no
// longer need to live behind a flag, so WeakMap gets added to the
snapshot.
if (FLAG_harmony_weakmaps) { // -- W e a k M a p
+ Handle<JSObject> prototype =
+ factory()->NewJSObject(isolate()->object_function(), TENURED);
InstallFunction(global, "WeakMap", JS_WEAK_MAP_TYPE, JSWeakMap::kSize,
- isolate->initial_object_prototype(),
- Builtins::kIllegal, true);
+ prototype, Builtins::kIllegal, true);
}
}
Index: src/weakmap.js
diff --git a/src/weakmap.js b/src/weakmap.js
index
70210b98de2d110b7781284ae20bf954d0c86993..3d261e5afda2e18502f3af41661b96cdd977258b
100644
--- a/src/weakmap.js
+++ b/src/weakmap.js
@@ -81,13 +81,16 @@ function WeakMapDelete(key) {
// -------------------------------------------------------------------
function SetupWeakMap() {
- // Setup the WeakMap constructor function.
+ // Set up the WeakMap constructor function.
%SetCode($WeakMap, WeakMapConstructor);
- // Setup the WeakMap prototype object.
+ // Set up the WeakMap prototype object.
%FunctionSetPrototype($WeakMap, new $WeakMap());
- // Setup the non-enumerable functions on the WeakMap prototype object.
+ // Set up the constructor property on the WeakMap prototype object.
+ %SetProperty($WeakMap.prototype, "constructor", $WeakMap, DONT_ENUM);
+
+ // Set up the non-enumerable functions on the WeakMap prototype object.
InstallFunctionsOnHiddenPrototype($WeakMap.prototype, DONT_ENUM, $Array(
"get", WeakMapGet,
"set", WeakMapSet,
Index: test/mjsunit/harmony/weakmaps.js
diff --git a/test/mjsunit/harmony/weakmaps.js
b/test/mjsunit/harmony/weakmaps.js
index
97f553cf29875e91ab64bdb2d56ea85b016cefc7..e43f9167e641b72ca4e440d211fd85bee367e9a0
100644
--- a/test/mjsunit/harmony/weakmaps.js
+++ b/test/mjsunit/harmony/weakmaps.js
@@ -137,6 +137,7 @@ assertTrue(WeakMap.prototype.set instanceof Function)
assertTrue(WeakMap.prototype.get instanceof Function)
assertTrue(WeakMap.prototype.has instanceof Function)
assertTrue(WeakMap.prototype.delete instanceof Function)
+assertTrue(WeakMap.prototype.constructor === WeakMap)
// Regression test for issue 1617: The prototype of the WeakMap constructor
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev