From 407f7741419ae72f0468f12e9b626ed609ac45e5 Mon Sep 17 00:00:00 2001 From: Igor Bukanov Date: Thu, 18 Jun 2009 15:00:55 +0200 Subject: [PATCH] Backed out changeset 7ab1be136cfa - that patch for bug 498899 has a bug. --- js/src/jsinterp.cpp | 22 +++++++++++++++------- js/src/jsinterp.h | 9 ++++++--- js/src/jslock.cpp | 11 ----------- js/src/jslock.h | 13 ------------- 4 files changed, 21 insertions(+), 34 deletions(-) diff --git a/js/src/jsinterp.cpp b/js/src/jsinterp.cpp index 561a711cd41c..7f5d49acf45b 100644 --- a/js/src/jsinterp.cpp +++ b/js/src/jsinterp.cpp @@ -433,13 +433,16 @@ js_FullTestPropertyCache(JSContext *cx, jsbytecode *pc, } pobj = obj; + JS_LOCK_OBJ(cx, pobj); if (JOF_MODE(cs->format) == JOF_NAME) { while (vcap & (PCVCAP_SCOPEMASK << PCVCAP_PROTOBITS)) { - tmp = OBJ_GET_PARENT(cx, pobj); + tmp = LOCKED_OBJ_GET_PARENT(pobj); if (!tmp || !OBJ_IS_NATIVE(tmp)) break; + JS_UNLOCK_OBJ(cx, pobj); pobj = tmp; + JS_LOCK_OBJ(cx, pobj); vcap -= PCVCAP_PROTOSIZE; } @@ -447,14 +450,16 @@ js_FullTestPropertyCache(JSContext *cx, jsbytecode *pc, } while (vcap & PCVCAP_PROTOMASK) { - tmp = OBJ_GET_PROTO(cx, pobj); + tmp = LOCKED_OBJ_GET_PROTO(pobj); if (!tmp || !OBJ_IS_NATIVE(tmp)) break; + JS_UNLOCK_OBJ(cx, pobj); pobj = tmp; + JS_LOCK_OBJ(cx, pobj); --vcap; } - if (JS_LOCK_OBJ_IF_SHAPE(cx, pobj, PCVCAP_SHAPE(vcap))) { + if (PCVCAP_SHAPE(vcap) == OBJ_SHAPE(pobj)) { #ifdef DEBUG jsid id = ATOM_TO_JSID(atom); @@ -467,6 +472,7 @@ js_FullTestPropertyCache(JSContext *cx, jsbytecode *pc, } PCMETER(JS_PROPERTY_CACHE(cx).vcmisses++); + JS_UNLOCK_OBJ(cx, pobj); return atom; } @@ -4635,13 +4641,13 @@ js_Interpret(JSContext *cx) PCVCAP_SHAPE(entry->vcap) == rt->protoHazardShape) { JS_ASSERT(PCVCAP_TAG(entry->vcap) == 0); - if (JS_LOCK_OBJ_IF_SHAPE(cx, obj, kshape)) { + JS_LOCK_OBJ(cx, obj); + JSScope *scope = OBJ_SCOPE(obj); + if (scope->shape == kshape) { JS_ASSERT(PCVAL_IS_SPROP(entry->vword)); sprop = PCVAL_TO_SPROP(entry->vword); JS_ASSERT(!(sprop->attrs & JSPROP_READONLY)); - - JSScope *scope = OBJ_SCOPE(obj); - JS_ASSERT(!SCOPE_IS_SEALED(scope)); + JS_ASSERT(!SCOPE_IS_SEALED(OBJ_SCOPE(obj))); /* * Fastest path: check whether the cached sprop is @@ -4770,6 +4776,8 @@ js_Interpret(JSContext *cx) PCMETER(cache->setpcmisses++); atom = NULL; } + + JS_UNLOCK_OBJ(cx, obj); } atom = js_FullTestPropertyCache(cx, regs.pc, &obj, &obj2, diff --git a/js/src/jsinterp.h b/js/src/jsinterp.h index 1f4be263a616..7cbcdcb87880 100644 --- a/js/src/jsinterp.h +++ b/js/src/jsinterp.h @@ -380,20 +380,23 @@ js_FillPropertyCache(JSContext *cx, JSObject *obj, if (entry->kpc == pc && entry->kshape == kshape_) { \ JSObject *tmp_; \ pobj = obj; \ + JS_LOCK_OBJ(cx, pobj); \ JS_ASSERT(PCVCAP_TAG(entry->vcap) <= 1); \ if (PCVCAP_TAG(entry->vcap) == 1 && \ - (tmp_ = OBJ_GET_PROTO(cx, pobj)) != NULL && \ + (tmp_ = LOCKED_OBJ_GET_PROTO(pobj)) != NULL && \ OBJ_IS_NATIVE(tmp_)) { \ + JS_UNLOCK_OBJ(cx, pobj); \ pobj = tmp_; \ + JS_LOCK_OBJ(cx, pobj); \ } \ - \ - if (JS_LOCK_OBJ_IF_SHAPE(cx, pobj, PCVCAP_SHAPE(entry->vcap))) { \ + if (PCVCAP_SHAPE(entry->vcap) == OBJ_SHAPE(pobj)) { \ PCMETER(cache_->pchits++); \ PCMETER(!PCVCAP_TAG(entry->vcap) || cache_->protopchits++); \ pobj = OBJ_SCOPE(pobj)->object; \ atom = NULL; \ break; \ } \ + JS_UNLOCK_OBJ(cx, pobj); \ } \ atom = js_FullTestPropertyCache(cx, pc, &obj, &pobj, &entry); \ if (atom) \ diff --git a/js/src/jslock.cpp b/js/src/jslock.cpp index 98ae26940e4c..eab89d473131 100644 --- a/js/src/jslock.cpp +++ b/js/src/jslock.cpp @@ -1422,17 +1422,6 @@ js_UnlockObj(JSContext *cx, JSObject *obj) js_UnlockTitle(cx, &OBJ_SCOPE(obj)->title); } -bool -js_LockObjIfShape(JSContext *cx, JSObject *obj, uint32 shape) -{ - JS_ASSERT(OBJ_SCOPE(obj)->title.ownercx != cx); - js_LockObj(cx, obj); - if (OBJ_SHAPE(obj) == shape) - return true; - js_UnlockObj(cx, obj); - return false; -} - void js_InitTitle(JSContext *cx, JSTitle *title) { diff --git a/js/src/jslock.h b/js/src/jslock.h index e466131861e7..bfa0c637d7be 100644 --- a/js/src/jslock.h +++ b/js/src/jslock.h @@ -160,16 +160,6 @@ struct JSTitle { #define JS_UNLOCK_OBJ(cx,obj) ((OBJ_SCOPE(obj)->title.ownercx == (cx)) \ ? (void)0 : js_UnlockObj(cx, obj)) -/* - * Lock object only if its scope has the given shape. - */ -#define JS_LOCK_OBJ_IF_SHAPE(cx,obj,shape) \ - (OBJ_SHAPE(obj) == (shape) \ - ? (OBJ_SCOPE(obj)->title.ownercx == (cx) \ - ? true \ - : js_LockObjIfShape(cx, obj, shape)) \ - : false) - #define JS_LOCK_TITLE(cx,title) \ ((title)->ownercx == (cx) ? (void)0 \ : (js_LockTitle(cx, (title)), \ @@ -191,7 +181,6 @@ extern void js_LockRuntime(JSRuntime *rt); extern void js_UnlockRuntime(JSRuntime *rt); extern void js_LockObj(JSContext *cx, JSObject *obj); extern void js_UnlockObj(JSContext *cx, JSObject *obj); -extern bool js_LockObjIfShape(JSContext *cx, JSObject *obj, uint32 shape); extern void js_InitTitle(JSContext *cx, JSTitle *title); extern void js_FinishTitle(JSContext *cx, JSTitle *title); extern void js_LockTitle(JSContext *cx, JSTitle *title); @@ -273,8 +262,6 @@ extern void js_SetScopeInfo(JSScope *scope, const char *file, int line); #define JS_UNLOCK_RUNTIME(rt) ((void)0) #define JS_LOCK_OBJ(cx,obj) ((void)0) #define JS_UNLOCK_OBJ(cx,obj) ((void)0) -#define JS_LOCK_OBJ_IF_SHAPE(cx,obj,shape) (OBJ_SHAPE(obj) == (shape)) - #define JS_LOCK_OBJ_VOID(cx,obj,e) (e) #define JS_LOCK_SCOPE(cx,scope) ((void)0) #define JS_UNLOCK_SCOPE(cx,scope) ((void)0)