/*
- * Copyright (C) 2012, 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2012, 2013, 2015 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
namespace JSC {
-int JSSegmentedVariableObject::findRegisterIndex(void* registerAddress)
+ScopeOffset JSSegmentedVariableObject::findVariableIndex(void* variableAddress)
{
ConcurrentJITLocker locker(m_lock);
- for (int i = m_registers.size(); i--;) {
- if (&m_registers[i] != registerAddress)
+ for (unsigned i = m_variables.size(); i--;) {
+ if (&m_variables[i] != variableAddress)
continue;
- return i;
+ return ScopeOffset(i);
}
CRASH();
- return -1;
+ return ScopeOffset();
}
-int JSSegmentedVariableObject::addRegisters(int numberOfRegistersToAdd)
+ScopeOffset JSSegmentedVariableObject::addVariables(unsigned numberOfVariablesToAdd)
{
ConcurrentJITLocker locker(m_lock);
- ASSERT(numberOfRegistersToAdd >= 0);
+ size_t oldSize = m_variables.size();
+ m_variables.grow(oldSize + numberOfVariablesToAdd);
- size_t oldSize = m_registers.size();
- m_registers.grow(oldSize + numberOfRegistersToAdd);
+ for (size_t i = numberOfVariablesToAdd; i--;)
+ m_variables[oldSize + i].setWithoutWriteBarrier(jsUndefined());
- for (size_t i = numberOfRegistersToAdd; i--;)
- m_registers[oldSize + i].setWithoutWriteBarrier(jsUndefined());
-
- return static_cast<int>(oldSize);
+ return ScopeOffset(oldSize);
}
void JSSegmentedVariableObject::visitChildren(JSCell* cell, SlotVisitor& slotVisitor)
{
JSSegmentedVariableObject* thisObject = jsCast<JSSegmentedVariableObject*>(cell);
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
- COMPILE_ASSERT(StructureFlags & OverridesVisitChildren, OverridesVisitChildrenWithoutSettingFlag);
- ASSERT(thisObject->structure()->typeInfo().overridesVisitChildren());
JSSymbolTableObject::visitChildren(thisObject, slotVisitor);
- for (unsigned i = thisObject->m_registers.size(); i--;)
- slotVisitor.append(&thisObject->m_registers[i]);
+ for (unsigned i = thisObject->m_variables.size(); i--;)
+ slotVisitor.append(&thisObject->m_variables[i]);
}
} // namespace JSC