Index: src/objects-inl.h |
diff --git a/src/objects-inl.h b/src/objects-inl.h |
index e5e8d55cce10b60c32e511c1b1e650195bf1f4f8..49159130df45f3e4f10e3ee8f4dbc6e17dbf368b 100644 |
--- a/src/objects-inl.h |
+++ b/src/objects-inl.h |
@@ -78,25 +78,35 @@ int PropertyDetails::field_width_in_words() const { |
int holder::name() const { return READ_INT_FIELD(this, offset); } \ |
void holder::set_##name(int value) { WRITE_INT_FIELD(this, offset, value); } |
- |
-#define ACCESSORS(holder, name, type, offset) \ |
- type* holder::name() const { return type::cast(READ_FIELD(this, offset)); } \ |
- void holder::set_##name(type* value, WriteBarrierMode mode) { \ |
- WRITE_FIELD(this, offset, value); \ |
- CONDITIONAL_WRITE_BARRIER(GetHeap(), this, offset, value, mode); \ |
+#define ACCESSORS_CHECKED(holder, name, type, offset, condition) \ |
+ type* holder::name() const { \ |
+ DCHECK(condition); \ |
+ return type::cast(READ_FIELD(this, offset)); \ |
+ } \ |
+ void holder::set_##name(type* value, WriteBarrierMode mode) { \ |
+ DCHECK(condition); \ |
+ WRITE_FIELD(this, offset, value); \ |
+ CONDITIONAL_WRITE_BARRIER(GetHeap(), this, offset, value, mode); \ |
} |
+#define ACCESSORS(holder, name, type, offset) \ |
+ ACCESSORS_CHECKED(holder, name, type, offset, true) |
// Getter that returns a Smi as an int and writes an int as a Smi. |
-#define SMI_ACCESSORS(holder, name, offset) \ |
- int holder::name() const { \ |
- Object* value = READ_FIELD(this, offset); \ |
- return Smi::cast(value)->value(); \ |
- } \ |
- void holder::set_##name(int value) { \ |
- WRITE_FIELD(this, offset, Smi::FromInt(value)); \ |
+#define SMI_ACCESSORS_CHECKED(holder, name, offset, condition) \ |
+ int holder::name() const { \ |
+ DCHECK(condition); \ |
+ Object* value = READ_FIELD(this, offset); \ |
+ return Smi::cast(value)->value(); \ |
+ } \ |
+ void holder::set_##name(int value) { \ |
+ DCHECK(condition); \ |
+ WRITE_FIELD(this, offset, Smi::FromInt(value)); \ |
} |
+#define SMI_ACCESSORS(holder, name, offset) \ |
+ SMI_ACCESSORS_CHECKED(holder, name, offset, true) |
+ |
#define SYNCHRONIZED_SMI_ACCESSORS(holder, name, offset) \ |
int holder::synchronized_##name() const { \ |
Object* value = ACQUIRE_READ_FIELD(this, offset); \ |
@@ -5651,12 +5661,18 @@ ACCESSORS(Script, context_data, Object, kContextOffset) |
ACCESSORS(Script, wrapper, HeapObject, kWrapperOffset) |
SMI_ACCESSORS(Script, type, kTypeOffset) |
ACCESSORS(Script, line_ends, Object, kLineEndsOffset) |
-ACCESSORS(Script, eval_from_shared, Object, kEvalFromSharedOffset) |
-SMI_ACCESSORS(Script, eval_from_position, kEvalFromPositionOffset) |
+ACCESSORS_CHECKED(Script, eval_from_shared, Object, kEvalFromSharedOffset, |
+ this->type() != TYPE_WASM) |
+SMI_ACCESSORS_CHECKED(Script, eval_from_position, kEvalFromPositionOffset, |
+ this->type() != TYPE_WASM) |
ACCESSORS(Script, shared_function_infos, Object, kSharedFunctionInfosOffset) |
SMI_ACCESSORS(Script, flags, kFlagsOffset) |
ACCESSORS(Script, source_url, Object, kSourceUrlOffset) |
ACCESSORS(Script, source_mapping_url, Object, kSourceMappingUrlOffset) |
+ACCESSORS_CHECKED(Script, wasm_object, JSObject, kEvalFromSharedOffset, |
+ this->type() == TYPE_WASM) |
+SMI_ACCESSORS_CHECKED(Script, wasm_function_index, kEvalFromPositionOffset, |
+ this->type() == TYPE_WASM) |
Script::CompilationType Script::compilation_type() { |
return BooleanBit::get(flags(), kCompilationTypeBit) ? |