OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <stdlib.h> | 5 #include <stdlib.h> |
6 | 6 |
7 #include "src/v8.h" | 7 #include "src/v8.h" |
8 | 8 |
9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
10 #include "src/scopeinfo.h" | 10 #include "src/scopeinfo.h" |
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 // Cache as not found. Mode, location, init flag and maybe assigned flag | 565 // Cache as not found. Mode, location, init flag and maybe assigned flag |
566 // don't matter. | 566 // don't matter. |
567 context_slot_cache->Update(scope_info, name, TEMPORARY, | 567 context_slot_cache->Update(scope_info, name, TEMPORARY, |
568 VariableLocation::CONTEXT, kNeedsInitialization, | 568 VariableLocation::CONTEXT, kNeedsInitialization, |
569 kNotAssigned, -1); | 569 kNotAssigned, -1); |
570 } | 570 } |
571 return -1; | 571 return -1; |
572 } | 572 } |
573 | 573 |
574 | 574 |
| 575 String* ScopeInfo::ContextSlotName(int slot_index) { |
| 576 // TODO(bmeurer): Simplify this once we have only a single slot for both reads |
| 577 // and writes to context globals; currently we have 2 slots per context |
| 578 // global, and these are located after the common context slots (of which we |
| 579 // always have Context::MIN_CONTEXT_SLOTS) and the context locals. |
| 580 int const var = |
| 581 slot_index - (Context::MIN_CONTEXT_SLOTS + ContextLocalCount()); |
| 582 DCHECK_LE(0, var); |
| 583 DCHECK_LT(var, 2 * ContextGlobalCount()); |
| 584 return ContextLocalName(ContextLocalCount() + var / 2); |
| 585 } |
| 586 |
| 587 |
575 int ScopeInfo::ParameterIndex(String* name) { | 588 int ScopeInfo::ParameterIndex(String* name) { |
576 DCHECK(name->IsInternalizedString()); | 589 DCHECK(name->IsInternalizedString()); |
577 if (length() > 0) { | 590 if (length() > 0) { |
578 // We must read parameters from the end since for | 591 // We must read parameters from the end since for |
579 // multiply declared parameters the value of the | 592 // multiply declared parameters the value of the |
580 // last declaration of that parameter is used | 593 // last declaration of that parameter is used |
581 // inside a function (and thus we need to look | 594 // inside a function (and thus we need to look |
582 // at the last index). Was bug# 1110337. | 595 // at the last index). Was bug# 1110337. |
583 int start = ParameterEntriesIndex(); | 596 int start = ParameterEntriesIndex(); |
584 int end = ParameterEntriesIndex() + ParameterCount(); | 597 int end = ParameterEntriesIndex() + ParameterCount(); |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
846 info->set_mode(i, var->mode()); | 859 info->set_mode(i, var->mode()); |
847 DCHECK(var->index() >= 0); | 860 DCHECK(var->index() >= 0); |
848 info->set_index(i, var->index()); | 861 info->set_index(i, var->index()); |
849 } | 862 } |
850 DCHECK(i == info->length()); | 863 DCHECK(i == info->length()); |
851 return info; | 864 return info; |
852 } | 865 } |
853 | 866 |
854 } // namespace internal | 867 } // namespace internal |
855 } // namespace v8 | 868 } // namespace v8 |
OLD | NEW |