Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IGNORE] Experiment 1 #15856

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 6 additions & 36 deletions third_party/move/move-vm/runtime/src/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1540,6 +1540,7 @@ impl CallStack {
}
}

#[allow(dead_code)]
fn check_depth_of_type(resolver: &Resolver, ty: &Type) -> PartialVMResult<()> {
// Start at 1 since we always call this right before we add a new node to the value's depth.
let max_depth = match resolver.vm_config().max_value_nest_depth {
Expand Down Expand Up @@ -1961,29 +1962,7 @@ impl Frame {
interpreter.operand_stack.push(field_ref)?;
},
Bytecode::Pack(sd_idx) => {
let get_field_count_charge_gas_and_check_depth =
|| -> PartialVMResult<u16> {
let field_count = resolver.field_count(*sd_idx);
let struct_type = resolver.get_struct_ty(*sd_idx);
check_depth_of_type(resolver, &struct_type)?;
Ok(field_count)
};

let field_count = if RTCaches::caches_enabled() {
let cached_field_count =
&frame_cache.per_instruction_cache[self.pc as usize];
if let PerInstructionCache::Pack(ref field_count) = cached_field_count {
*field_count
} else {
let field_count = get_field_count_charge_gas_and_check_depth()?;
frame_cache.per_instruction_cache[self.pc as usize] =
PerInstructionCache::Pack(field_count);
field_count
}
} else {
get_field_count_charge_gas_and_check_depth()?
};

let field_count = resolver.field_count(*sd_idx);
gas_meter.charge_pack(
false,
interpreter.operand_stack.last_n(field_count as usize)?,
Expand All @@ -1995,8 +1974,6 @@ impl Frame {
},
Bytecode::PackVariant(idx) => {
let info = resolver.get_struct_variant_at(*idx);
let struct_type = resolver.create_struct_ty(&info.definition_struct_type);
check_depth_of_type(resolver, &struct_type)?;
gas_meter.charge_pack_variant(
false,
interpreter
Expand Down Expand Up @@ -2025,10 +2002,9 @@ impl Frame {
gas_meter.charge_create_ty(*ty_count)?;
}

let (ty, ty_count) =
let (_, ty_count) =
frame_cache.get_struct_type(*si_idx, resolver, ty_args)?;
gas_meter.charge_create_ty(ty_count)?;
check_depth_of_type(resolver, ty)?;
Ok(resolver.field_instantiation_count(*si_idx))
};

Expand Down Expand Up @@ -2069,10 +2045,9 @@ impl Frame {
gas_meter.charge_create_ty(*ty_count)?;
}

let (ty, ty_count) =
let (_, ty_count) =
frame_cache.get_struct_variant_type(*si_idx, resolver, ty_args)?;
gas_meter.charge_create_ty(ty_count)?;
check_depth_of_type(resolver, ty)?;

let info = resolver.get_struct_variant_instantiation_at(*si_idx);
gas_meter.charge_pack_variant(
Expand Down Expand Up @@ -2120,12 +2095,10 @@ impl Frame {
gas_meter.charge_create_ty(*ty_count)?;
}

let (ty, ty_count) =
let (_, ty_count) =
frame_cache.get_struct_type(*si_idx, resolver, ty_args)?;
gas_meter.charge_create_ty(ty_count)?;

check_depth_of_type(resolver, ty)?;

let struct_ = interpreter.operand_stack.pop_as::<Struct>()?;

gas_meter.charge_unpack(true, struct_.field_views())?;
Expand All @@ -2145,12 +2118,10 @@ impl Frame {
gas_meter.charge_create_ty(*ty_count)?;
}

let (ty, ty_count) =
let (_, ty_count) =
frame_cache.get_struct_variant_type(*si_idx, resolver, ty_args)?;
gas_meter.charge_create_ty(ty_count)?;

check_depth_of_type(resolver, ty)?;

let struct_ = interpreter.operand_stack.pop_as::<Struct>()?;

gas_meter.charge_unpack_variant(true, struct_.field_views())?;
Expand Down Expand Up @@ -2446,7 +2417,6 @@ impl Frame {
self.function.ty_args(),
)?;
gas_meter.charge_create_ty(ty_count)?;
check_depth_of_type(resolver, ty)?;
gas_meter.charge_vec_pack(
make_ty!(ty),
interpreter.operand_stack.last_n(*num as usize)?,
Expand Down
Loading