| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 if (index >= 0) return false; | 233 if (index >= 0) return false; |
| 234 context = Context::cast(context->closure()->context()); | 234 context = Context::cast(context->closure()->context()); |
| 235 } | 235 } |
| 236 | 236 |
| 237 // No local or potential with statement found so the variable is | 237 // No local or potential with statement found so the variable is |
| 238 // global unless it is shadowed by an eval-introduced variable. | 238 // global unless it is shadowed by an eval-introduced variable. |
| 239 return true; | 239 return true; |
| 240 } | 240 } |
| 241 | 241 |
| 242 | 242 |
| 243 void Context::AddOptimizedFunction(JSFunction* function) { |
| 244 ASSERT(IsGlobalContext()); |
| 245 #ifdef DEBUG |
| 246 Object* element = get(OPTIMIZED_FUNCTIONS_LIST); |
| 247 while (!element->IsUndefined()) { |
| 248 CHECK(element != function); |
| 249 element = JSFunction::cast(element)->next_function_link(); |
| 250 } |
| 251 |
| 252 CHECK(function->next_function_link()->IsUndefined()); |
| 253 |
| 254 // Check that the context belongs to the weak global contexts list. |
| 255 bool found = false; |
| 256 Object* context = GetHeap()->global_contexts_list(); |
| 257 while (!context->IsUndefined()) { |
| 258 if (context == this) { |
| 259 found = true; |
| 260 break; |
| 261 } |
| 262 context = Context::cast(context)->get(Context::NEXT_CONTEXT_LINK); |
| 263 } |
| 264 CHECK(found); |
| 265 #endif |
| 266 function->set_next_function_link(get(OPTIMIZED_FUNCTIONS_LIST)); |
| 267 set(OPTIMIZED_FUNCTIONS_LIST, function); |
| 268 } |
| 269 |
| 270 |
| 271 void Context::RemoveOptimizedFunction(JSFunction* function) { |
| 272 ASSERT(IsGlobalContext()); |
| 273 Object* element = get(OPTIMIZED_FUNCTIONS_LIST); |
| 274 JSFunction* prev = NULL; |
| 275 while (!element->IsUndefined()) { |
| 276 JSFunction* element_function = JSFunction::cast(element); |
| 277 ASSERT(element_function->next_function_link()->IsUndefined() || |
| 278 element_function->next_function_link()->IsJSFunction()); |
| 279 if (element_function == function) { |
| 280 if (prev == NULL) { |
| 281 set(OPTIMIZED_FUNCTIONS_LIST, element_function->next_function_link()); |
| 282 } else { |
| 283 prev->set_next_function_link(element_function->next_function_link()); |
| 284 } |
| 285 element_function->set_next_function_link(GetHeap()->undefined_value()); |
| 286 return; |
| 287 } |
| 288 prev = element_function; |
| 289 element = element_function->next_function_link(); |
| 290 } |
| 291 UNREACHABLE(); |
| 292 } |
| 293 |
| 294 |
| 295 Object* Context::OptimizedFunctionsListHead() { |
| 296 ASSERT(IsGlobalContext()); |
| 297 return get(OPTIMIZED_FUNCTIONS_LIST); |
| 298 } |
| 299 |
| 300 |
| 301 void Context::ClearOptimizedFunctions() { |
| 302 set(OPTIMIZED_FUNCTIONS_LIST, GetHeap()->undefined_value()); |
| 303 } |
| 304 |
| 305 |
| 243 #ifdef DEBUG | 306 #ifdef DEBUG |
| 244 bool Context::IsBootstrappingOrContext(Object* object) { | 307 bool Context::IsBootstrappingOrContext(Object* object) { |
| 245 // During bootstrapping we allow all objects to pass as | 308 // During bootstrapping we allow all objects to pass as |
| 246 // contexts. This is necessary to fix circular dependencies. | 309 // contexts. This is necessary to fix circular dependencies. |
| 247 return Isolate::Current()->bootstrapper()->IsActive() || object->IsContext(); | 310 return Isolate::Current()->bootstrapper()->IsActive() || object->IsContext(); |
| 248 } | 311 } |
| 249 | 312 |
| 250 | 313 |
| 251 bool Context::IsBootstrappingOrGlobalObject(Object* object) { | 314 bool Context::IsBootstrappingOrGlobalObject(Object* object) { |
| 252 // During bootstrapping we allow all objects to pass as global | 315 // During bootstrapping we allow all objects to pass as global |
| 253 // objects. This is necessary to fix circular dependencies. | 316 // objects. This is necessary to fix circular dependencies. |
| 254 Isolate* isolate = Isolate::Current(); | 317 Isolate* isolate = Isolate::Current(); |
| 255 return isolate->heap()->gc_state() != Heap::NOT_IN_GC || | 318 return isolate->heap()->gc_state() != Heap::NOT_IN_GC || |
| 256 isolate->bootstrapper()->IsActive() || | 319 isolate->bootstrapper()->IsActive() || |
| 257 object->IsGlobalObject(); | 320 object->IsGlobalObject(); |
| 258 } | 321 } |
| 259 #endif | 322 #endif |
| 260 | 323 |
| 261 } } // namespace v8::internal | 324 } } // namespace v8::internal |
| OLD | NEW |