| 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 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 } | 477 } |
| 478 return -1; | 478 return -1; |
| 479 } | 479 } |
| 480 | 480 |
| 481 | 481 |
| 482 template<class Allocator> | 482 template<class Allocator> |
| 483 int ScopeInfo<Allocator>::FunctionContextSlotIndex(Code* code, String* name) { | 483 int ScopeInfo<Allocator>::FunctionContextSlotIndex(Code* code, String* name) { |
| 484 ASSERT(name->IsSymbol()); | 484 ASSERT(name->IsSymbol()); |
| 485 if (code->sinfo_size() > 0) { | 485 if (code->sinfo_size() > 0) { |
| 486 Object** p = &Memory::Object_at(code->sinfo_start()); | 486 Object** p = &Memory::Object_at(code->sinfo_start()); |
| 487 if (*p++ == name) { | 487 if (*p == name) { |
| 488 int n; | 488 p = ContextEntriesAddr(code); |
| 489 ReadInt(p, &n); // n = number of context slots | 489 int n; // number of context slots |
| 490 return n -1; // the function context slot is the last entry | 490 ReadInt(p, &n); |
| 491 ASSERT(n != 0); |
| 492 // The function context slot is the last entry. |
| 493 return n + Context::MIN_CONTEXT_SLOTS - 1; |
| 491 } | 494 } |
| 492 } | 495 } |
| 493 return -1; | 496 return -1; |
| 494 } | 497 } |
| 495 | 498 |
| 496 | 499 |
| 497 template<class Allocator> | 500 template<class Allocator> |
| 498 Handle<String> ScopeInfo<Allocator>::LocalName(int i) const { | 501 Handle<String> ScopeInfo<Allocator>::LocalName(int i) const { |
| 499 // A local variable can be allocated either on the stack or in the context. | 502 // A local variable can be allocated either on the stack or in the context. |
| 500 // For variables allocated in the context they are always preceded by the | 503 // For variables allocated in the context they are always preceded by the |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 PrintF("}\n"); | 562 PrintF("}\n"); |
| 560 } | 563 } |
| 561 #endif // DEBUG | 564 #endif // DEBUG |
| 562 | 565 |
| 563 | 566 |
| 564 // Make sure the classes get instantiated by the template system. | 567 // Make sure the classes get instantiated by the template system. |
| 565 template class ScopeInfo<FreeStoreAllocationPolicy>; | 568 template class ScopeInfo<FreeStoreAllocationPolicy>; |
| 566 template class ScopeInfo<PreallocatedStorage>; | 569 template class ScopeInfo<PreallocatedStorage>; |
| 567 | 570 |
| 568 } } // namespace v8::internal | 571 } } // namespace v8::internal |
| OLD | NEW |