Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(435)

Side by Side Diff: src/contexts.cc

Issue 7152002: Change the representation of catch contexts. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/contexts.h ('k') | src/factory.h » ('j') | src/runtime.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 91
92 do { 92 do {
93 if (FLAG_trace_contexts) { 93 if (FLAG_trace_contexts) {
94 PrintF(" - looking in context %p", reinterpret_cast<void*>(*context)); 94 PrintF(" - looking in context %p", reinterpret_cast<void*>(*context));
95 if (context->IsGlobalContext()) PrintF(" (global context)"); 95 if (context->IsGlobalContext()) PrintF(" (global context)");
96 PrintF("\n"); 96 PrintF("\n");
97 } 97 }
98 98
99 // Check extension/with/global object. 99 // Check extension/with/global object.
100 if (context->has_extension()) { 100 if (context->has_extension()) {
101 Handle<JSObject> extension = Handle<JSObject>(context->extension(), 101 if (context->IsCatchContext()) {
102 isolate); 102 // Catch contexts have the variable name in the extension slot.
103 // Context extension objects needs to behave as if they have no 103 if (name->Equals(String::cast(context->extension()))) {
Søren Thygesen Gjesse 2011/06/14 12:23:31 Dbc. Should context perhaps have a method GetCatch
104 // prototype. So even if we want to follow prototype chains, we 104 if (FLAG_trace_contexts) {
105 // need to only do a local lookup for context extension objects. 105 PrintF("=> found in catch context\n");
106 if ((flags & FOLLOW_PROTOTYPE_CHAIN) == 0 || 106 }
107 extension->IsJSContextExtensionObject()) { 107 *index_ = Context::THROWN_OBJECT_INDEX;
108 *attributes = extension->GetLocalPropertyAttribute(*name); 108 *attributes = NONE;
109 return context;
110 }
109 } else { 111 } else {
110 *attributes = extension->GetPropertyAttribute(*name); 112 // Global, function, and with contexts may have an object in the
111 } 113 // extension slot.
112 if (*attributes != ABSENT) { 114 Handle<JSObject> extension(JSObject::cast(context->extension()),
113 // property found 115 isolate);
114 if (FLAG_trace_contexts) { 116 // Context extension objects needs to behave as if they have no
115 PrintF("=> found property in context object %p\n", 117 // prototype. So even if we want to follow prototype chains, we
116 reinterpret_cast<void*>(*extension)); 118 // need to only do a local lookup for context extension objects.
119 if ((flags & FOLLOW_PROTOTYPE_CHAIN) == 0 ||
120 extension->IsJSContextExtensionObject()) {
121 *attributes = extension->GetLocalPropertyAttribute(*name);
122 } else {
123 *attributes = extension->GetPropertyAttribute(*name);
117 } 124 }
118 return extension; 125 if (*attributes != ABSENT) {
126 // property found
127 if (FLAG_trace_contexts) {
128 PrintF("=> found property in context object %p\n",
129 reinterpret_cast<void*>(*extension));
130 }
131 return extension;
132 }
119 } 133 }
120 } 134 }
121 135
122 // Only functions can have locals, parameters, and a function name. 136 // Only functions can have locals, parameters, and a function name.
123 if (context->IsFunctionContext()) { 137 if (context->IsFunctionContext()) {
124 // we have context-local slots 138 // we have context-local slots
125 139
126 // check non-parameter locals in context 140 // check non-parameter locals in context
127 Handle<SerializedScopeInfo> scope_info( 141 Handle<SerializedScopeInfo> scope_info(
128 context->closure()->shared()->scope_info(), isolate); 142 context->closure()->shared()->scope_info(), isolate);
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 // During bootstrapping we allow all objects to pass as global 352 // During bootstrapping we allow all objects to pass as global
339 // objects. This is necessary to fix circular dependencies. 353 // objects. This is necessary to fix circular dependencies.
340 Isolate* isolate = Isolate::Current(); 354 Isolate* isolate = Isolate::Current();
341 return isolate->heap()->gc_state() != Heap::NOT_IN_GC || 355 return isolate->heap()->gc_state() != Heap::NOT_IN_GC ||
342 isolate->bootstrapper()->IsActive() || 356 isolate->bootstrapper()->IsActive() ||
343 object->IsGlobalObject(); 357 object->IsGlobalObject();
344 } 358 }
345 #endif 359 #endif
346 360
347 } } // namespace v8::internal 361 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/contexts.h ('k') | src/factory.h » ('j') | src/runtime.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698