Guard an unsafe cast of a catch context's extension object.

R=ager@chromium.org
BUG=
TEST=

Review URL: http://codereview.chromium.org/7149019

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8283 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent dc47de67
...@@ -224,8 +224,8 @@ bool Context::GlobalIfNotShadowedByEval(Handle<String> name) { ...@@ -224,8 +224,8 @@ bool Context::GlobalIfNotShadowedByEval(Handle<String> name) {
// before the global context and check that there are no context // before the global context and check that there are no context
// extension objects (conservative check for with statements). // extension objects (conservative check for with statements).
while (!context->IsGlobalContext()) { while (!context->IsGlobalContext()) {
// Check if the context is a catch or with context, or has called // Check if the context is a catch or with context, or has introduced
// non-strict eval. // bindings by calling non-strict eval.
if (context->has_extension()) return false; if (context->has_extension()) return false;
// Not a with context so it must be a function context. // Not a with context so it must be a function context.
......
...@@ -303,6 +303,10 @@ class Context: public FixedArray { ...@@ -303,6 +303,10 @@ class Context: public FixedArray {
Map* map = this->map(); Map* map = this->map();
return map == map->GetHeap()->catch_context_map(); return map == map->GetHeap()->catch_context_map();
} }
bool IsWithContext() {
Map* map = this->map();
return map == map->GetHeap()->with_context_map();
}
// Tells whether the global context is marked with out of memory. // Tells whether the global context is marked with out of memory.
inline bool has_out_of_memory(); inline bool has_out_of_memory();
......
...@@ -3228,8 +3228,8 @@ bool JSObject::ReferencesObject(Object* obj) { ...@@ -3228,8 +3228,8 @@ bool JSObject::ReferencesObject(Object* obj) {
} }
} }
// Check the context extension if any. // Check the context extension (if any) if it can have references.
if (context->has_extension()) { if (context->has_extension() && !context->IsCatchContext()) {
return JSObject::cast(context->extension())->ReferencesObject(obj); return JSObject::cast(context->extension())->ReferencesObject(obj);
} }
} }
......
...@@ -1232,6 +1232,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_DeclareContextSlot) { ...@@ -1232,6 +1232,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_DeclareContextSlot) {
// Declarations are always done in the function context. // Declarations are always done in the function context.
context = Handle<Context>(context->fcontext()); context = Handle<Context>(context->fcontext());
ASSERT(context->IsFunctionContext());
int index; int index;
PropertyAttributes attributes; PropertyAttributes attributes;
...@@ -10227,8 +10228,8 @@ class ScopeIterator { ...@@ -10227,8 +10228,8 @@ class ScopeIterator {
} else if (context_->IsFunctionContext()) { } else if (context_->IsFunctionContext()) {
at_local_ = true; at_local_ = true;
} else if (context_->closure() != *function_) { } else if (context_->closure() != *function_) {
// The context_ is a with block from the outer function. // The context_ is a with or catch block from the outer function.
ASSERT(context_->has_extension()); ASSERT(context_->IsWithContext() || context_->IsCatchContext());
at_local_ = true; at_local_ = true;
} }
} }
...@@ -10280,10 +10281,10 @@ class ScopeIterator { ...@@ -10280,10 +10281,10 @@ class ScopeIterator {
if (context_->IsFunctionContext()) { if (context_->IsFunctionContext()) {
return ScopeTypeClosure; return ScopeTypeClosure;
} }
ASSERT(context_->has_extension());
if (context_->IsCatchContext()) { if (context_->IsCatchContext()) {
return ScopeTypeCatch; return ScopeTypeCatch;
} }
ASSERT(context_->IsWithContext());
return ScopeTypeWith; return ScopeTypeWith;
} }
......
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