From 4a498bde249a525b2ad8d0a841fe621403b8891b Mon Sep 17 00:00:00 2001 From: Terrence Cole Date: Thu, 19 Dec 2013 16:55:40 -0800 Subject: [PATCH] Bug 952285 - Clarify some code in TypeRepresentation for the hazard analysis; r=nmatsakis --HG-- extra : rebase_source : dce9b8d79f645fd90e4049bf18e3056b25fd1740 --- js/src/builtin/TypeRepresentation.cpp | 28 +++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/js/src/builtin/TypeRepresentation.cpp b/js/src/builtin/TypeRepresentation.cpp index 10eedf9fee27..3f92f6ef8996 100644 --- a/js/src/builtin/TypeRepresentation.cpp +++ b/js/src/builtin/TypeRepresentation.cpp @@ -453,8 +453,11 @@ class TypeRepresentationHelper { static JSObject *CreateSimple(JSContext *cx, typename T::Type type) { JSCompartment *comp = cx->compartment(); - T sample(type); - TypeRepresentationHash::AddPtr p = comp->typeReprs.lookupForAdd(&sample); + TypeRepresentationHash::AddPtr p; + { + T sample(type); + p = comp->typeReprs.lookupForAdd(&sample); + } if (p) return (*p)->ownerObject(); @@ -492,8 +495,11 @@ ReferenceTypeRepresentation::Create(JSContext *cx, { JSCompartment *comp = cx->compartment(); - ReferenceTypeRepresentation sample(type); - TypeRepresentationHash::AddPtr p = comp->typeReprs.lookupForAdd(&sample); + TypeRepresentationHash::AddPtr p; + { + ReferenceTypeRepresentation sample(type); + p = comp->typeReprs.lookupForAdd(&sample); + } if (p) return (*p)->ownerObject(); @@ -526,8 +532,11 @@ SizedArrayTypeRepresentation::Create(JSContext *cx, return nullptr; } - SizedArrayTypeRepresentation sample(element, length); - TypeRepresentationHash::AddPtr p = comp->typeReprs.lookupForAdd(&sample); + TypeRepresentationHash::AddPtr p; + { + SizedArrayTypeRepresentation sample(element, length); + p = comp->typeReprs.lookupForAdd(&sample); + } if (p) return (*p)->ownerObject(); @@ -550,8 +559,11 @@ UnsizedArrayTypeRepresentation::Create(JSContext *cx, { JSCompartment *comp = cx->compartment(); - UnsizedArrayTypeRepresentation sample(element); - TypeRepresentationHash::AddPtr p = comp->typeReprs.lookupForAdd(&sample); + TypeRepresentationHash::AddPtr p; + { + UnsizedArrayTypeRepresentation sample(element); + p = comp->typeReprs.lookupForAdd(&sample); + } if (p) return (*p)->ownerObject();