Skip to content

Commit

Permalink
Fix minor code defects
Browse files Browse the repository at this point in the history
Signed-off-by: HyukWoo Park <[email protected]>
  • Loading branch information
clover2123 committed Jul 24, 2023
1 parent 498966b commit 2d7dac5
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 34 deletions.
12 changes: 4 additions & 8 deletions src/interpreter/ByteCodeInterpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ OpcodeTable::OpcodeTable()
class InterpreterSlowPath {
public:
static Value loadByName(ExecutionState& state, LexicalEnvironment* env, const AtomicString& name, bool throwException = true);
static EnvironmentRecord* getBindedEnvironmentRecordByName(ExecutionState& state, LexicalEnvironment* env, const AtomicString& name, Value& bindedValue, bool throwException = true);
static EnvironmentRecord* getBindedEnvironmentRecordByName(ExecutionState& state, LexicalEnvironment* env, const AtomicString& name, Value& bindedValue);
static void storeByName(ExecutionState& state, LexicalEnvironment* env, const AtomicString& name, const Value& value);
static void initializeByName(ExecutionState& state, LexicalEnvironment* env, const AtomicString& name, bool isLexicallyDeclaredName, const Value& value);
static void resolveNameAddress(ExecutionState& state, ResolveNameAddress* code, Value* registerFile);
Expand Down Expand Up @@ -1682,7 +1682,7 @@ Value Interpreter::interpret(ExecutionState* state, ByteCodeBlock* byteCodeBlock
return Value();
}

NEVER_INLINE EnvironmentRecord* InterpreterSlowPath::getBindedEnvironmentRecordByName(ExecutionState& state, LexicalEnvironment* env, const AtomicString& name, Value& bindedValue, bool throwException)
NEVER_INLINE EnvironmentRecord* InterpreterSlowPath::getBindedEnvironmentRecordByName(ExecutionState& state, LexicalEnvironment* env, const AtomicString& name, Value& bindedValue)
{
while (env) {
EnvironmentRecord::GetBindingValueResult result = env->record()->getBindingValue(state, name);
Expand All @@ -1693,9 +1693,7 @@ NEVER_INLINE EnvironmentRecord* InterpreterSlowPath::getBindedEnvironmentRecordB
env = env->outerEnvironment();
}

if (throwException)
ErrorObject::throwBuiltinError(state, ErrorCode::ReferenceError, name.string(), false, String::emptyString, ErrorObject::Messages::IsNotDefined);

ErrorObject::throwBuiltinError(state, ErrorCode::ReferenceError, name.string(), false, String::emptyString, ErrorObject::Messages::IsNotDefined);
return NULL;
}

Expand Down Expand Up @@ -3675,9 +3673,7 @@ NEVER_INLINE void InterpreterSlowPath::callFunctionComplexCase(ExecutionState& s
Object* receiverObj = NULL;
Value callee;
EnvironmentRecord* bindedRecord = getBindedEnvironmentRecordByName(state, state.lexicalEnvironment(), calleeName, callee);
if (!bindedRecord) {
callee = Value();
}
ASSERT(!!bindedRecord);

if (bindedRecord && bindedRecord->isObjectEnvironmentRecord()) {
receiverObj = bindedRecord->asObjectEnvironmentRecord()->bindingObject();
Expand Down
10 changes: 0 additions & 10 deletions src/runtime/EnvironmentRecord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -536,16 +536,6 @@ EnvironmentRecord::GetBindingValueResult ModuleEnvironmentRecord::getBindingValu
return GetBindingValueResult();
}

Value ModuleEnvironmentRecord::getBindingValue(ExecutionState& state, const size_t i)
{
if (m_moduleBindings[i].m_targetRecord) {
return m_moduleBindings[i].m_targetRecord->getBindingValue(state, m_moduleBindings[i].m_targetBindingName).m_value;
} else {
readCheck(state, i);
return m_moduleBindings[i].m_value;
}
}

void ModuleEnvironmentRecord::setHeapValueByIndex(ExecutionState& state, const size_t idx, const Value& v)
{
writeCheck(state, idx);
Expand Down
6 changes: 0 additions & 6 deletions src/runtime/EnvironmentRecord.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,6 @@ class EnvironmentRecord : public gc {
return GetBindingValueResult();
}

virtual Value getBindingValue(ExecutionState& state, const size_t idx)
{
RELEASE_ASSERT_NOT_REACHED();
}

virtual bool deleteBinding(ExecutionState& state, const AtomicString& name)
{
RELEASE_ASSERT_NOT_REACHED();
Expand Down Expand Up @@ -1230,7 +1225,6 @@ class ModuleEnvironmentRecord : public DeclarativeEnvironmentRecord {
virtual void setMutableBindingByIndex(ExecutionState& state, const size_t i, const Value& v) override;
virtual void initializeBindingByIndex(ExecutionState& state, const size_t idx, const Value& v) override;
virtual GetBindingValueResult getBindingValue(ExecutionState& state, const AtomicString& name) override;
virtual Value getBindingValue(ExecutionState& state, const size_t i) override;
virtual void setHeapValueByIndex(ExecutionState& state, const size_t idx, const Value& v) override;
virtual Value getHeapValueByIndex(ExecutionState& state, const size_t idx) override;
Script* script()
Expand Down
14 changes: 7 additions & 7 deletions src/runtime/ExecutionState.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,19 @@ class NativeFunctionObject;
typedef Vector<ControlFlowRecord*, GCUtil::gc_malloc_allocator<ControlFlowRecord*>> ControlFlowRecordVector;

struct ExecutionStateRareData : public gc {
ControlFlowRecordVector* m_controlFlowRecord;
ExecutionState* m_parent;
CodeBlock* m_codeBlock;
ControlFlowRecordVector* m_controlFlowRecord;
ExecutionPauser* m_pauseSource;
ExecutionState* m_parent;
size_t m_programCounterWhenItStoppedByYield;

ExecutionStateRareData()
: m_codeBlock(nullptr)
, m_controlFlowRecord(nullptr)
, m_pauseSource(nullptr)
, m_parent(nullptr)
, m_programCounterWhenItStoppedByYield(SIZE_MAX)
{
m_codeBlock = nullptr;
m_controlFlowRecord = nullptr;
m_pauseSource = nullptr;
m_parent = nullptr;
m_programCounterWhenItStoppedByYield = SIZE_MAX;
}
};

Expand Down
2 changes: 1 addition & 1 deletion src/runtime/GlobalObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,7 @@ static Value builtinArrayToString(ExecutionState& state, Value thisValue, size_t
return Object::call(state, toString, thisObject, 0, nullptr);
}

Value builtinGenericIteratorNext(ExecutionState& state, Value thisValue, size_t argc, Value* argv, Optional<Object*> newTarget)
static Value builtinGenericIteratorNext(ExecutionState& state, Value thisValue, size_t argc, Value* argv, Optional<Object*> newTarget)
{
if (!thisValue.isObject() || !thisValue.asObject()->isGenericIteratorObject()) {
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, String::fromASCII("Iterator"), true, state.context()->staticStrings().next.string(), ErrorObject::Messages::GlobalObject_CalledOnIncompatibleReceiver);
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/SandBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ bool SandBox::createStackTrace(StackTraceDataVector& stackTraceDataVector, Execu
return false;
}

void SandBox::throwException(ExecutionState& state, Value exception)
void SandBox::throwException(ExecutionState& state, const Value& exception)
{
m_stackTraceDataVector.clear();
createStackTrace(m_stackTraceDataVector, state);
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/SandBox.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class SandBox : public gc {

static bool createStackTrace(StackTraceDataVector& stackTraceDataVector, ExecutionState& state, bool stopAtPause = false);

void throwException(ExecutionState& state, Value exception);
void throwException(ExecutionState& state, const Value& exception);
void rethrowPreviouslyCaughtException(ExecutionState& state, Value exception, const StackTraceDataVector& stackTraceDataVector);

StackTraceDataVector& stackTraceDataVector()
Expand Down

0 comments on commit 2d7dac5

Please sign in to comment.