From 5e727c8c5dced9c39530ef05ffc21deba4125752 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Thu, 18 Dec 2008 16:32:18 -0700 Subject: [PATCH] throw an error if a volatile field is encountered, since we don't yet support them properly --- src/compile.cpp | 2 ++ src/interpret.cpp | 6 ++++++ src/process.h | 15 +++++++++++++++ 3 files changed, 23 insertions(+) diff --git a/src/compile.cpp b/src/compile.cpp index d9367bfd4c..44e27ed088 100644 --- a/src/compile.cpp +++ b/src/compile.cpp @@ -2483,6 +2483,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip, object field = resolveField(t, codePool(t, code), index - 1); if (UNLIKELY(t->exception)) return; + if (throwIfVolatileField(t, field)) return; Compiler::Operand* table; @@ -3363,6 +3364,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip, object field = resolveField(t, codePool(t, code), index - 1); if (UNLIKELY(t->exception)) return; + if (throwIfVolatileField(t, field)) return; object staticTable = 0; diff --git a/src/interpret.cpp b/src/interpret.cpp index db55168865..72421baf6a 100644 --- a/src/interpret.cpp +++ b/src/interpret.cpp @@ -1452,6 +1452,7 @@ interpret(Thread* t) object field = resolveField(t, codePool(t, code), index - 1); if (UNLIKELY(exception)) goto throw_; + if (throwIfVolatileField(t, field)) goto throw_; pushField(t, popObject(t), field); } else { @@ -1465,6 +1466,8 @@ interpret(Thread* t) object field = resolveField(t, codePool(t, code), index - 1); if (UNLIKELY(exception)) goto throw_; + if (throwIfVolatileField(t, field)) goto throw_; + PROTECT(t, field); if (UNLIKELY(classInit(t, fieldClass(t, field), 3))) goto invoke; @@ -2396,6 +2399,7 @@ interpret(Thread* t) object field = resolveField(t, codePool(t, code), index - 1); if (UNLIKELY(exception)) goto throw_; + if (throwIfVolatileField(t, field)) goto throw_; switch (fieldCode(t, field)) { case ByteField: @@ -2461,6 +2465,8 @@ interpret(Thread* t) object field = resolveField(t, codePool(t, code), index - 1); if (UNLIKELY(exception)) goto throw_; + if (throwIfVolatileField(t, field)) goto throw_; + PROTECT(t, field); if (UNLIKELY(classInit(t, fieldClass(t, field), 3))) goto invoke; diff --git a/src/process.h b/src/process.h index 78c231b307..8be25c0bd0 100644 --- a/src/process.h +++ b/src/process.h @@ -188,6 +188,21 @@ populateMultiArray(Thread* t, object array, int32_t* counts, int findLineNumber(Thread* t, object method, unsigned ip); +inline bool +throwIfVolatileField(Thread* t, object field) +{ + if (fieldFlags(t, field) & ACC_VOLATILE) { + object message = makeString + (t, "volatile fields are not yet supported: %s.%s", + &byteArrayBody(t, className(t, fieldClass(t, field)), 0), + &byteArrayBody(t, fieldName(t, field), 0)); + t->exception = makeNoSuchFieldError(t, message); + return true; + } else { + return false; + } +} + } // namespace vm #endif//PROCESS_H