diff --git a/third_party/move/move-binary-format/src/check_bounds.rs b/third_party/move/move-binary-format/src/check_bounds.rs index 2e9f40388d969..1992a22e47968 100644 --- a/third_party/move/move-binary-format/src/check_bounds.rs +++ b/third_party/move/move-binary-format/src/check_bounds.rs @@ -658,8 +658,8 @@ impl<'a> BoundsChecker<'a> { | VecPopBack(idx) | VecUnpack(idx, _) | VecSwap(idx) - | Invoke(idx) - | EarlyBind(idx, _) => { + | InvokeFunction(idx) + | EarlyBindFunction(idx, _) => { self.check_code_unit_bounds_impl( self.view.signatures(), *idx, diff --git a/third_party/move/move-binary-format/src/check_complexity.rs b/third_party/move/move-binary-format/src/check_complexity.rs index 4aff6b1bfd7e9..78310559d7b96 100644 --- a/third_party/move/move-binary-format/src/check_complexity.rs +++ b/third_party/move/move-binary-format/src/check_complexity.rs @@ -292,8 +292,8 @@ impl<'a> BinaryComplexityMeter<'a> { | VecPopBack(idx) | VecUnpack(idx, _) | VecSwap(idx) - | Invoke(idx) - | EarlyBind(idx, _) => { + | InvokeFunction(idx) + | EarlyBindFunction(idx, _) => { self.meter_signature(*idx)?; }, diff --git a/third_party/move/move-binary-format/src/deserializer.rs b/third_party/move/move-binary-format/src/deserializer.rs index 24f096ef482c9..fcfcd33b192db 100644 --- a/third_party/move/move-binary-format/src/deserializer.rs +++ b/third_party/move/move-binary-format/src/deserializer.rs @@ -1825,10 +1825,11 @@ fn load_code(cursor: &mut VersionedCursor, code: &mut Vec) -> BinaryLo Opcodes::LD_FUNCTION_GENERIC => { Bytecode::LdFunctionGeneric(load_function_inst_index(cursor)?) }, - Opcodes::INVOKE => Bytecode::Invoke(load_signature_index(cursor)?), - Opcodes::EARLY_BIND => { - Bytecode::EarlyBind(load_signature_index(cursor)?, read_u8_internal(cursor)?) - }, + Opcodes::INVOKE_FUNCTION => Bytecode::InvokeFunction(load_signature_index(cursor)?), + Opcodes::EARLY_BIND_FUNCTION => Bytecode::EarlyBindFunction( + load_signature_index(cursor)?, + read_u8_internal(cursor)?, + ), }; code.push(bytecode); } diff --git a/third_party/move/move-binary-format/src/file_format.rs b/third_party/move/move-binary-format/src/file_format.rs index 4d431f5c319e2..a2137420e3226 100644 --- a/third_party/move/move-binary-format/src/file_format.rs +++ b/third_party/move/move-binary-format/src/file_format.rs @@ -2988,7 +2988,7 @@ pub enum Bytecode { #[group = "closure"] #[description = r#" - `EarlyBind(|t1..tn|r with a, count)` creates new function value based + `EarlyBindFunction(|t1..tn|r with a, count)` creates new function value based on the function value at top of stack by adding `count` arguments popped from the stack to the closure found on top of stack. @@ -3024,11 +3024,11 @@ pub enum Bytecode { func param types match provided parameter types "#] #[gas_type_creation_tier_0 = "closure_ty"] - EarlyBind(SignatureIndex, u8), + EarlyBindFunction(SignatureIndex, u8), #[group = "closure"] #[description = r#" - `Invoke(|t1..tn|r with a)` calls a function value of the specified type, + `InvokeFunction(|t1..tn|r with a)` calls a function value of the specified type, with `n` argument values from the stack. On top of the stack is the closure being evaluated, underneath the arguments: @@ -3095,7 +3095,7 @@ pub enum Bytecode { assert ty == locals[#args - i - 1] "#] #[gas_type_creation_tier_1 = "closure_ty"] - Invoke(SignatureIndex), + InvokeFunction(SignatureIndex), #[group = "stack_and_local"] #[description = "Push a u16 constant onto the stack."] @@ -3209,8 +3209,10 @@ impl ::std::fmt::Debug for Bytecode { Bytecode::UnpackVariantGeneric(a) => write!(f, "UnpackVariantGeneric({})", a), Bytecode::LdFunction(a) => write!(f, "LdFunction({})", a), Bytecode::LdFunctionGeneric(a) => write!(f, "LdFunctionGeneric({})", a), - Bytecode::EarlyBind(sig_idx, a) => write!(f, "EarlyBind({}, {})", sig_idx, a), - Bytecode::Invoke(sig_idx) => write!(f, "Invoke({})", sig_idx), + Bytecode::EarlyBindFunction(sig_idx, a) => { + write!(f, "EarlyBindFunction({}, {})", sig_idx, a) + }, + Bytecode::InvokeFunction(sig_idx) => write!(f, "InvokeFunction({})", sig_idx), Bytecode::ReadRef => write!(f, "ReadRef"), Bytecode::WriteRef => write!(f, "WriteRef"), Bytecode::FreezeRef => write!(f, "FreezeRef"), diff --git a/third_party/move/move-binary-format/src/file_format_common.rs b/third_party/move/move-binary-format/src/file_format_common.rs index 0627507bf1b71..3fa19710d9176 100644 --- a/third_party/move/move-binary-format/src/file_format_common.rs +++ b/third_party/move/move-binary-format/src/file_format_common.rs @@ -302,8 +302,8 @@ pub enum Opcodes { // Closures LD_FUNCTION = 0x58, LD_FUNCTION_GENERIC = 0x59, - INVOKE = 0x5A, - EARLY_BIND = 0x5B, + INVOKE_FUNCTION = 0x5A, + EARLY_BIND_FUNCTION = 0x5B, } /// Upper limit on the binary size @@ -797,8 +797,8 @@ pub fn instruction_key(instruction: &Bytecode) -> u8 { // Since bytecode version 8 LdFunction(_) => Opcodes::LD_FUNCTION, LdFunctionGeneric(_) => Opcodes::LD_FUNCTION_GENERIC, - Invoke(_) => Opcodes::INVOKE, - EarlyBind(..) => Opcodes::EARLY_BIND, + InvokeFunction(_) => Opcodes::INVOKE_FUNCTION, + EarlyBindFunction(..) => Opcodes::EARLY_BIND_FUNCTION, }; opcode as u8 } diff --git a/third_party/move/move-binary-format/src/serializer.rs b/third_party/move/move-binary-format/src/serializer.rs index e6e66657c19a7..686df2927b1fa 100644 --- a/third_party/move/move-binary-format/src/serializer.rs +++ b/third_party/move/move-binary-format/src/serializer.rs @@ -1104,12 +1104,12 @@ fn serialize_instruction_inner( binary.push(Opcodes::LD_FUNCTION_GENERIC as u8)?; serialize_function_inst_index(binary, method_idx) }, - Bytecode::Invoke(sig_idx) => { - binary.push(Opcodes::INVOKE as u8)?; + Bytecode::InvokeFunction(sig_idx) => { + binary.push(Opcodes::INVOKE_FUNCTION as u8)?; serialize_signature_index(binary, sig_idx) }, - Bytecode::EarlyBind(sig_idx, value) => { - binary.push(Opcodes::EARLY_BIND as u8)?; + Bytecode::EarlyBindFunction(sig_idx, value) => { + binary.push(Opcodes::EARLY_BIND_FUNCTION as u8)?; serialize_signature_index(binary, sig_idx)?; binary.push(*value) }, diff --git a/third_party/move/move-bytecode-verifier/invalid-mutations/src/bounds/code_unit.rs b/third_party/move/move-bytecode-verifier/invalid-mutations/src/bounds/code_unit.rs index 934aca14890b7..ce9a0a537a8f3 100644 --- a/third_party/move/move-bytecode-verifier/invalid-mutations/src/bounds/code_unit.rs +++ b/third_party/move/move-bytecode-verifier/invalid-mutations/src/bounds/code_unit.rs @@ -514,7 +514,7 @@ impl<'a> ApplyCodeUnitBoundsContext<'a> { FunctionInstantiationIndex, LdFunctionGeneric ), - Invoke(..) | EarlyBind(..) => { + InvokeFunction(..) | EarlyBindFunction(..) => { panic!("Closure bytecode NYI: {:?}", code[bytecode_idx]) }, }; @@ -576,7 +576,7 @@ fn is_interesting(bytecode: &Bytecode) -> bool { | LdFalse | ReadRef | WriteRef | Add | Sub | Mul | Mod | Div | BitOr | BitAnd | Xor | Shl | Shr | Or | And | Not | Eq | Neq | Lt | Gt | Le | Ge | Abort | Nop => false, - LdFunction(_) | LdFunctionGeneric(_) | Invoke(_) | EarlyBind(..) => { + LdFunction(_) | LdFunctionGeneric(_) | InvokeFunction(_) | EarlyBindFunction(..) => { // TODO(LAMBDA): implement false }, diff --git a/third_party/move/move-bytecode-verifier/src/acquires_list_verifier.rs b/third_party/move/move-bytecode-verifier/src/acquires_list_verifier.rs index 41d5282ac05ea..f7c3de60ff1d1 100644 --- a/third_party/move/move-bytecode-verifier/src/acquires_list_verifier.rs +++ b/third_party/move/move-bytecode-verifier/src/acquires_list_verifier.rs @@ -107,8 +107,8 @@ impl<'a> AcquiresVerifier<'a> { let fi = self.module.function_instantiation_at(*idx); self.ld_function_acquire(fi.handle, offset) }, - Bytecode::EarlyBind(_sig_idx, _count) => Ok(()), - Bytecode::Invoke(_sig_idx) => self.invoke_acquire(offset), + Bytecode::EarlyBindFunction(_sig_idx, _count) => Ok(()), + Bytecode::InvokeFunction(_sig_idx) => self.invoke_acquire(offset), Bytecode::Pop | Bytecode::BrTrue(_) @@ -216,7 +216,7 @@ impl<'a> AcquiresVerifier<'a> { offset: CodeOffset, ) -> PartialVMResult<()> { // Currenty we are disallowing acquires for any function value which - // is created, so Invoke does nothing with acquires. + // is created, so InvokeFunction does nothing with acquires. // TODO(LAMBDA) In the future this may change. let function_handle = self.module.function_handle_at(fh_idx); let function_acquired_resources = self.function_acquired_resources(function_handle, fh_idx); @@ -228,7 +228,7 @@ impl<'a> AcquiresVerifier<'a> { fn invoke_acquire(&mut self, _offset: CodeOffset) -> PartialVMResult<()> { // Currenty we are disallowing acquires for any function value which - // is created, so Invoke does nothing with acquires. + // is created, so InvokeFunction does nothing with acquires. // TODO(LAMBDA) In the future this may change. Ok(()) } diff --git a/third_party/move/move-bytecode-verifier/src/instruction_consistency.rs b/third_party/move/move-bytecode-verifier/src/instruction_consistency.rs index fdba5d7033813..6a00182700d90 100644 --- a/third_party/move/move-bytecode-verifier/src/instruction_consistency.rs +++ b/third_party/move/move-bytecode-verifier/src/instruction_consistency.rs @@ -104,11 +104,11 @@ impl<'a> InstructionConsistency<'a> { let func_inst = self.resolver.function_instantiation_at(*idx); self.check_ld_function_op(offset, func_inst.handle, /* generic */ true)?; }, - Invoke(sig_idx) => { + InvokeFunction(sig_idx) => { // reuse code to check for signature issues. self.check_bind_count(offset, *sig_idx, 0)?; }, - EarlyBind(sig_idx, count) => { + EarlyBindFunction(sig_idx, count) => { self.check_bind_count(offset, *sig_idx, *count)?; }, Pack(idx) | Unpack(idx) => { diff --git a/third_party/move/move-bytecode-verifier/src/locals_safety/mod.rs b/third_party/move/move-bytecode-verifier/src/locals_safety/mod.rs index 006f102eedbb4..cf6bc86a7a2d4 100644 --- a/third_party/move/move-bytecode-verifier/src/locals_safety/mod.rs +++ b/third_party/move/move-bytecode-verifier/src/locals_safety/mod.rs @@ -127,8 +127,8 @@ fn execute_inner( | Bytecode::TestVariantGeneric(_) | Bytecode::LdFunction(_) | Bytecode::LdFunctionGeneric(_) - | Bytecode::Invoke(_) - | Bytecode::EarlyBind(..) + | Bytecode::InvokeFunction(_) + | Bytecode::EarlyBindFunction(..) | Bytecode::ReadRef | Bytecode::WriteRef | Bytecode::CastU8 diff --git a/third_party/move/move-bytecode-verifier/src/reference_safety/abstract_state.rs b/third_party/move/move-bytecode-verifier/src/reference_safety/abstract_state.rs index e8bfe35827a0f..23e94aa17cf1d 100644 --- a/third_party/move/move-bytecode-verifier/src/reference_safety/abstract_state.rs +++ b/third_party/move/move-bytecode-verifier/src/reference_safety/abstract_state.rs @@ -576,14 +576,14 @@ impl AbstractState { ) -> PartialVMResult { if !acquired_resources.is_empty() { // TODO(LAMBDA): Currently acquires must be empty unless we disallow - // Invoke to call to functions defined in the same module. + // InvokeFunction to call to functions defined in the same module. return Err(self.error(StatusCode::INVALID_ACQUIRES_ANNOTATION, offset)); } // TODO(LAMBDA): Double-check that we don't need meter adjustments here. Ok(AbstractValue::NonReference) } - pub fn invoke( + pub fn invoke_function( &mut self, offset: CodeOffset, arguments: Vec, diff --git a/third_party/move/move-bytecode-verifier/src/reference_safety/mod.rs b/third_party/move/move-bytecode-verifier/src/reference_safety/mod.rs index d8426892e30cf..80f3127a0b8a2 100644 --- a/third_party/move/move-bytecode-verifier/src/reference_safety/mod.rs +++ b/third_party/move/move-bytecode-verifier/src/reference_safety/mod.rs @@ -125,7 +125,7 @@ fn ld_function( Ok(()) } -fn early_bind( +fn early_bind_function( verifier: &mut ReferenceSafetyAnalysis, _arg_tys: Vec, k: u8, @@ -140,7 +140,7 @@ fn early_bind( Ok(()) } -fn invoke( +fn invoke_function( verifier: &mut ReferenceSafetyAnalysis, state: &mut AbstractState, offset: CodeOffset, @@ -153,7 +153,7 @@ fn invoke( .map(|_| verifier.stack.pop().unwrap()) .rev() .collect(); - let values = state.invoke(offset, arguments, &result_tys, meter)?; + let values = state.invoke_function(offset, arguments, &result_tys, meter)?; for value in values { verifier.stack.push(value) } @@ -578,13 +578,13 @@ fn execute_inner( let function_handle = verifier.resolver.function_handle_at(func_inst.handle); ld_function(verifier, state, offset, function_handle, meter)? }, - Bytecode::EarlyBind(sig_idx, k) => { + Bytecode::EarlyBindFunction(sig_idx, k) => { let (arg_tys, _result_tys) = fun_type(verifier, *sig_idx)?; - early_bind(verifier, arg_tys, *k)? + early_bind_function(verifier, arg_tys, *k)? }, - Bytecode::Invoke(sig_idx) => { + Bytecode::InvokeFunction(sig_idx) => { let (arg_tys, result_tys) = fun_type(verifier, *sig_idx)?; - invoke(verifier, state, offset, arg_tys, result_tys, meter)? + invoke_function(verifier, state, offset, arg_tys, result_tys, meter)? }, Bytecode::VecPack(idx, num) => { diff --git a/third_party/move/move-bytecode-verifier/src/signature.rs b/third_party/move/move-bytecode-verifier/src/signature.rs index e2c7068d56573..a7b2d4372c9ab 100644 --- a/third_party/move/move-bytecode-verifier/src/signature.rs +++ b/third_party/move/move-bytecode-verifier/src/signature.rs @@ -260,7 +260,10 @@ impl<'a> SignatureChecker<'a> { }, // Closure operations not supported by legacy signature checker - LdFunction(..) | LdFunctionGeneric(..) | Invoke(_) | EarlyBind(..) => { + LdFunction(..) + | LdFunctionGeneric(..) + | InvokeFunction(_) + | EarlyBindFunction(..) => { return Err(PartialVMError::new(StatusCode::UNEXPECTED_VERIFIER_ERROR) .with_message("closure operations not supported".to_owned())) }, diff --git a/third_party/move/move-bytecode-verifier/src/signature_v2.rs b/third_party/move/move-bytecode-verifier/src/signature_v2.rs index 953c26005d921..6a9eccf8ce9a5 100644 --- a/third_party/move/move-bytecode-verifier/src/signature_v2.rs +++ b/third_party/move/move-bytecode-verifier/src/signature_v2.rs @@ -900,12 +900,12 @@ impl<'a, const N: usize> SignatureChecker<'a, N> { entry.insert(()); } }, - Invoke(idx) => map_err(self.verify_fun_sig_idx( + InvokeFunction(idx) => map_err(self.verify_fun_sig_idx( *idx, &mut checked_fun_insts, &ability_context, ))?, - EarlyBind(idx, count) => { + EarlyBindFunction(idx, count) => { map_err(self.verify_fun_sig_idx( *idx, &mut checked_fun_insts, @@ -922,7 +922,7 @@ impl<'a, const N: usize> SignatureChecker<'a, N> { return map_err(Err(PartialVMError::new( StatusCode::NUMBER_OF_ARGUMENTS_MISMATCH, ) - .with_message("in EarlyBind".to_string()))); + .with_message("in EarlyBindFunction".to_string()))); }; }; entry.insert(()); @@ -1142,7 +1142,7 @@ impl<'a, const N: usize> SignatureChecker<'a, N> { Ok(()) } - // Checks that a `sig_idx` parameter to `Invoke` or `EarlyBind` is well-formed. + // Checks that a `sig_idx` parameter to `InvokeFunction` or `EarlyBindFunction` is well-formed. fn verify_fun_sig_idx( &self, idx: SignatureIndex, diff --git a/third_party/move/move-bytecode-verifier/src/stack_usage_verifier.rs b/third_party/move/move-bytecode-verifier/src/stack_usage_verifier.rs index bb86abdcc346a..a76f2aab3d2af 100644 --- a/third_party/move/move-bytecode-verifier/src/stack_usage_verifier.rs +++ b/third_party/move/move-bytecode-verifier/src/stack_usage_verifier.rs @@ -239,9 +239,9 @@ impl<'a> StackUsageVerifier<'a> { (0, 1) }, - // Invoke pops a function and the number of arguments and pushes the results of the + // InvokeFunction pops a function and the number of arguments and pushes the results of the // given function type - Bytecode::Invoke(idx) => { + Bytecode::InvokeFunction(idx) => { if let Some(SignatureToken::Function(args, results, _)) = self.resolver.signature_at(*idx).0.first() { @@ -253,8 +253,8 @@ impl<'a> StackUsageVerifier<'a> { } }, - // EarlyBind pops a function value and the captured arguments and returns 1 value - Bytecode::EarlyBind(idx, arg_count) => { + // EarlyBindFunction pops a function value and the captured arguments and returns 1 value + Bytecode::EarlyBindFunction(idx, arg_count) => { if let Some(SignatureToken::Function(args, _results, _)) = self.resolver.signature_at(*idx).0.first() { diff --git a/third_party/move/move-bytecode-verifier/src/type_safety.rs b/third_party/move/move-bytecode-verifier/src/type_safety.rs index 66b8dd4bced7d..bc1bb05d03336 100644 --- a/third_party/move/move-bytecode-verifier/src/type_safety.rs +++ b/third_party/move/move-bytecode-verifier/src/type_safety.rs @@ -301,7 +301,7 @@ fn call( Ok(()) } -fn invoke( +fn invoke_function( verifier: &mut TypeSafetyChecker, meter: &mut impl Meter, offset: CodeOffset, @@ -391,7 +391,7 @@ fn ld_function( ) } -fn early_bind( +fn early_bind_function( verifier: &mut TypeSafetyChecker, meter: &mut impl Meter, offset: CodeOffset, @@ -881,16 +881,16 @@ fn verify_instr( ld_function(verifier, meter, offset, &func_inst.handle, type_args)? }, - Bytecode::EarlyBind(idx, count) => { + Bytecode::EarlyBindFunction(idx, count) => { // The signature checker has verified this is a function type. let expected_ty = safe_unwrap!(verifier.resolver.signature_at(*idx).0.first()); - early_bind(verifier, meter, offset, expected_ty, *count)? + early_bind_function(verifier, meter, offset, expected_ty, *count)? }, - Bytecode::Invoke(idx) => { + Bytecode::InvokeFunction(idx) => { // The signature checker has verified this is a function type. let expected_ty = safe_unwrap!(verifier.resolver.signature_at(*idx).0.first()); - invoke(verifier, meter, offset, expected_ty)? + invoke_function(verifier, meter, offset, expected_ty)? }, Bytecode::Pack(idx) => { diff --git a/third_party/move/move-compiler-v2/src/bytecode_generator.rs b/third_party/move/move-compiler-v2/src/bytecode_generator.rs index e6be8ca0e80c5..e93c5ab2b5a7f 100644 --- a/third_party/move/move-compiler-v2/src/bytecode_generator.rs +++ b/third_party/move/move-compiler-v2/src/bytecode_generator.rs @@ -499,7 +499,7 @@ impl<'env> Generator<'env> { } ), // TODO(LAMBDA) - ExpData::Invoke(id, _exp, _) => self.error( + ExpData::InvokeFunction(id, _exp, _) => self.error( *id, if self.check_if_lambdas_enabled() { "Calls to function values other than inline function parameters not yet implemented" @@ -816,7 +816,7 @@ impl<'env> Generator<'env> { self.gen_function_call(targets, id, m.qualified(*f), args) }, // TODO(LAMBDA) - Operation::EarlyBind => self.error( + Operation::EarlyBindFunction => self.error( id, if self.check_if_lambdas_enabled() { "Function-typed values not yet implemented except as parameters to calls to inline functions" diff --git a/third_party/move/move-compiler-v2/src/env_pipeline/ast_simplifier.rs b/third_party/move/move-compiler-v2/src/env_pipeline/ast_simplifier.rs index 62c9a6cf63d12..2beaf57e7156d 100644 --- a/third_party/move/move-compiler-v2/src/env_pipeline/ast_simplifier.rs +++ b/third_party/move/move-compiler-v2/src/env_pipeline/ast_simplifier.rs @@ -346,7 +346,7 @@ fn find_possibly_modified_vars( }, }; }, - Invoke(..) | Return(..) | Quant(..) | Loop(..) | Mutate(..) | SpecBlock(..) => { + InvokeFunction(..) | Return(..) | Quant(..) | Loop(..) | Mutate(..) | SpecBlock(..) => { // We don't modify top-level variables here. match pos { VisitorPosition::Pre => { diff --git a/third_party/move/move-compiler-v2/src/env_pipeline/lambda_lifter.rs b/third_party/move/move-compiler-v2/src/env_pipeline/lambda_lifter.rs index b7426dc5f20c9..f83adf74a98b9 100644 --- a/third_party/move/move-compiler-v2/src/env_pipeline/lambda_lifter.rs +++ b/third_party/move/move-compiler-v2/src/env_pipeline/lambda_lifter.rs @@ -13,9 +13,9 @@ //! not modify free variables. //! //! Lambda lifting rewrites lambda expressions into construction -//! of *closures* using the `EarlyBind` operation. A closure refers to a function and contains a list +//! of *closures* using the `EarlyBindFunction` operation. A closure refers to a function and contains a list //! of "early bound" leading arguments for that function, essentially currying it. We use the -//! `EarlyBind` operation to construct a closure from a function and set of arguments, +//! `EarlyBindFunction` operation to construct a closure from a function and set of arguments, //! which must be the first `k` arguments to the function argument list. //! //! ```ignore @@ -23,7 +23,7 @@ //! vec.any(|x| x > c) //! ==> //! let c = 1; -//! vec.any(EarlyBind(lifted, c)) +//! vec.any(EarlyBindFunction(lifted, c)) //! where //! fun lifted(c: u64, x: u64): bool { x > c } //! ``` @@ -36,7 +36,7 @@ //! vec.any(|S{x}| x > c) //! ==> //! let c = 1; -//! vec.any(EarlyBind(lifted, c)) +//! vec.any(EarlyBindFunction(lifted, c)) //! where //! fun lifted(c: u64, arg$2: S): bool { let S{x} = arg$2; x > y } //! ``` @@ -297,7 +297,7 @@ impl<'a> LambdaLifter<'a> { None } }, - Invalid(..) | Call(..) | Invoke(..) | Lambda(..) | Quant(..) | Block(..) + Invalid(..) | Call(..) | InvokeFunction(..) | Lambda(..) | Quant(..) | Block(..) | IfElse(..) | Match(..) | Return(..) | Loop(..) | LoopCont(..) | Assign(..) | Mutate(..) | SpecBlock(..) => None, } @@ -340,7 +340,7 @@ impl<'a> LambdaLifter<'a> { fn exp_is_simple(exp: &Exp) -> bool { use ExpData::*; match exp.as_ref() { - Call(_, Operation::EarlyBind, args) => args.iter().all(Self::exp_is_simple), + Call(_, Operation::EarlyBindFunction, args) => args.iter().all(Self::exp_is_simple), Call(_, op, args) => { op.is_ok_to_remove_from_code() && args.iter().all(Self::exp_is_simple) }, @@ -360,7 +360,7 @@ impl<'a> LambdaLifter<'a> { false }, LocalVar(..) | Temporary(..) | Value(..) => true, - Invalid(..) | Invoke(..) | Quant(..) | Block(..) | Match(..) | Return(..) + Invalid(..) | InvokeFunction(..) | Quant(..) | Block(..) | Match(..) | Return(..) | Loop(..) | LoopCont(..) | Assign(..) | Mutate(..) | SpecBlock(..) => false, } } @@ -416,7 +416,7 @@ impl<'a> LambdaLifter<'a> { match body.as_ref() { Call(id, oper, args) => { match oper { - Operation::EarlyBind => { + Operation::EarlyBindFunction => { // TODO(LAMBDA): We might be able to to do something with this, // but skip for now because it will be complicated. None @@ -438,7 +438,7 @@ impl<'a> LambdaLifter<'a> { _ => None, } }, - Invoke(_id, fn_exp, args) => { + InvokeFunction(_id, fn_exp, args) => { Self::get_args_if_simple(lambda_params, args).and_then(|args| { // Function expression may not contain lambda params let free_vars = fn_exp.as_ref().free_vars(); @@ -497,7 +497,7 @@ impl<'a> LambdaLifter<'a> { let fn_id = fn_exp.node_id(); let fn_type = env.get_node_type(fn_id); if let Type::Fun(_fn_param_type, _fn_result_type, fun_abilities) = &fn_type { - // First param to EarlyBind is the function expr + // First param to EarlyBindFunction is the function expr new_args.insert(0, fn_exp); let ty_params = self.fun_env.get_type_parameters_ref(); // Check bound value abilities @@ -556,7 +556,9 @@ impl<'a> LambdaLifter<'a> { // We have no parameters, just use the function directly. return Some(new_args.pop().unwrap()); } else { - return Some(ExpData::Call(id, Operation::EarlyBind, new_args).into_exp()); + return Some( + ExpData::Call(id, Operation::EarlyBindFunction, new_args).into_exp(), + ); } } } @@ -798,7 +800,7 @@ impl<'a> ExpRewriterFunctions for LambdaLifter<'a> { env.set_node_instantiation(id, inst); } closure_args.insert(0, fn_exp); - Some(ExpData::Call(id, Operation::EarlyBind, closure_args).into_exp()) + Some(ExpData::Call(id, Operation::EarlyBindFunction, closure_args).into_exp()) } } } diff --git a/third_party/move/move-compiler-v2/src/lib.rs b/third_party/move/move-compiler-v2/src/lib.rs index 84eda127b9f03..5ff3a597d509a 100644 --- a/third_party/move/move-compiler-v2/src/lib.rs +++ b/third_party/move/move-compiler-v2/src/lib.rs @@ -244,8 +244,9 @@ pub fn run_bytecode_gen(env: &GlobalEnv) -> FunctionTargetsHolder { if module.is_target() { for fun in module.get_functions() { let id = fun.get_qualified_id(); - // Skip inline functions because invoke and lambda are not supported in the current code generator + // Skip inline functions because invoke_function and lambda are not supported in the current code generator if !fun.is_inline() { + // TODO(LAMBDA) todo.insert(id); } } diff --git a/third_party/move/move-core/types/src/vm_status.rs b/third_party/move/move-core/types/src/vm_status.rs index 9aaccff1feecd..0776f84d760b3 100644 --- a/third_party/move/move-core/types/src/vm_status.rs +++ b/third_party/move/move-core/types/src/vm_status.rs @@ -734,7 +734,7 @@ pub enum StatusCode { ZERO_VARIANTS_ERROR = 1130, // A feature is not enabled. FEATURE_NOT_ENABLED = 1131, - // Invoke or EarlyBind parameter type is not a function + // InvokeFunction or EarlyBindFunction parameter type is not a function REQUIRES_FUNCTION = 1132, // Reserved error code for future use diff --git a/third_party/move/move-model/bytecode/src/stackless_bytecode_generator.rs b/third_party/move/move-model/bytecode/src/stackless_bytecode_generator.rs index f83916b3b4e87..9e498ea434537 100644 --- a/third_party/move/move-model/bytecode/src/stackless_bytecode_generator.rs +++ b/third_party/move/move-model/bytecode/src/stackless_bytecode_generator.rs @@ -293,10 +293,10 @@ impl<'a> StacklessBytecodeGenerator<'a> { }; match bytecode { - MoveBytecode::Invoke(..) + MoveBytecode::InvokeFunction(..) | MoveBytecode::LdFunction(..) | MoveBytecode::LdFunctionGeneric(..) - | MoveBytecode::EarlyBind(..) => { + | MoveBytecode::EarlyBindFunction(..) => { unimplemented!("stackless bytecode generation for closure opcodes") }, MoveBytecode::Pop => { diff --git a/third_party/move/move-model/src/ast.rs b/third_party/move/move-model/src/ast.rs index 7c5e120fd9de7..4f05b8cfb474f 100644 --- a/third_party/move/move-model/src/ast.rs +++ b/third_party/move/move-model/src/ast.rs @@ -639,7 +639,7 @@ pub enum ExpData { /// (including operators, constants, ...) as well as user functions. Call(NodeId, Operation, Vec), /// Represents an invocation of a function value, as a lambda. - Invoke(NodeId, Exp, Vec), + InvokeFunction(NodeId, Exp, Vec), /// Represents a lambda. Lambda(NodeId, Pattern, Exp, LambdaCaptureKind, AbilitySet), /// Represents a quantified formula over multiple variables and ranges. @@ -820,7 +820,7 @@ impl ExpData { | LocalVar(node_id, ..) | Temporary(node_id, ..) | Call(node_id, ..) - | Invoke(node_id, ..) + | InvokeFunction(node_id, ..) | Lambda(node_id, ..) | Quant(node_id, ..) | Block(node_id, ..) @@ -1435,7 +1435,7 @@ impl ExpData { exp.visit_positions_impl(visitor)?; } }, - Invoke(_, target, args) => { + InvokeFunction(_, target, args) => { target.visit_positions_impl(visitor)?; for exp in args { exp.visit_positions_impl(visitor)?; @@ -1819,9 +1819,9 @@ pub enum Operation { /// arguments will be bound, in order, to the leading parameters of that function, /// generating a function which takes the remaining parameters and then calls /// the function with the complete set of parameters. - /// (move |x, y| f(z, x, y)) === ExpData::Call(_, EarlyBind, vec![f, z]) - /// (move || f(z, x, y)) === ExpData::Call(_, EarlyBind, vec![f, z, x, y]) - EarlyBind, + /// (move |x, y| f(z, x, y)) === ExpData::Call(_, EarlyBindFunction, vec![f, z]) + /// (move || f(z, x, y)) === ExpData::Call(_, EarlyBindFunction, vec![f, z, x, y]) + EarlyBindFunction, Pack(ModuleId, StructId, /*variant*/ Option), Tuple, Select(ModuleId, StructId, FieldId), @@ -2674,7 +2674,7 @@ impl Operation { Select(..) => false, // Move-related SelectVariants(..) => false, // Move-related UpdateField(..) => false, // Move-related - EarlyBind => true, + EarlyBindFunction => true, // Specification specific Result(..) => false, // Spec @@ -2888,7 +2888,7 @@ impl ExpData { is_pure = false; } }, - Invoke(..) => { + InvokeFunction(..) => { // Leave it alone for now, but with more analysis maybe we can do something. is_pure = false; }, @@ -3340,7 +3340,7 @@ impl<'a> fmt::Display for ExpDisplay<'a> { body.display_cont(self) ) }, - Invoke(_, fun, args) => { + InvokeFunction(_, fun, args) => { write!(f, "({})({})", fun.display_cont(self), self.fmt_exps(args)) }, IfElse(_, cond, if_exp, else_exp) => { @@ -3571,7 +3571,7 @@ impl<'a> fmt::Display for OperationDisplay<'a> { .unwrap_or_else(|| "".to_string()) ) }, - EarlyBind => { + EarlyBindFunction => { write!(f, "earlybind") }, Global(label_opt) => { diff --git a/third_party/move/move-model/src/builder/exp_builder.rs b/third_party/move/move-model/src/builder/exp_builder.rs index f91e4dd28bd9f..98892bab334b6 100644 --- a/third_party/move/move-model/src/builder/exp_builder.rs +++ b/third_party/move/move-model/src/builder/exp_builder.rs @@ -1552,7 +1552,7 @@ impl<'env, 'translator, 'module_translator> ExpTranslator<'env, 'translator, 'mo ); let fexp = self.translate_exp(efexp, &fun_t); let id = self.new_node_id_with_type_loc(expected_type, &loc); - ExpData::Invoke(id, fexp.into_exp(), args) + ExpData::InvokeFunction(id, fexp.into_exp(), args) }, EA::Exp_::Pack(maccess, generics, fields) => self .translate_pack( @@ -3226,7 +3226,7 @@ impl<'env, 'translator, 'module_translator> ExpTranslator<'env, 'translator, 'mo if let EA::ModuleAccess_::Name(n) = &maccess.value { let sym = self.symbol_pool().make(&n.value); - // Check whether this is an Invoke on a function value. + // Check whether this is an InvokeFunction on a function value. if let Some(entry) = self.lookup_local(sym, false) { // Check whether the local has the expected function type. let sym_ty = entry.type_.clone(); @@ -3246,7 +3246,7 @@ impl<'env, 'translator, 'module_translator> ExpTranslator<'env, 'translator, 'mo let local_id = self.new_node_id_with_type_loc(&sym_ty, &self.to_loc(&n.loc)); let local_var = ExpData::LocalVar(local_id, sym); let id = self.new_node_id_with_type_loc(expected_type, loc); - return Some(ExpData::Invoke(id, local_var.into_exp(), args)); + return Some(ExpData::InvokeFunction(id, local_var.into_exp(), args)); } if self.is_spec_mode() { diff --git a/third_party/move/move-model/src/exp_rewriter.rs b/third_party/move/move-model/src/exp_rewriter.rs index af93e0e72553f..d7b0138b9de41 100644 --- a/third_party/move/move-model/src/exp_rewriter.rs +++ b/third_party/move/move-model/src/exp_rewriter.rs @@ -341,7 +341,7 @@ pub trait ExpRewriterFunctions { exp } }, - Invoke(id, target, args) => { + InvokeFunction(id, target, args) => { let (id_changed, new_id) = self.internal_rewrite_id(*id); let (target_changed, new_target) = self.internal_rewrite_exp(target); let new_args_opt = self.internal_rewrite_vec(args); @@ -358,7 +358,7 @@ pub trait ExpRewriterFunctions { } else { args.to_owned() }; - Invoke(new_id, new_target, args_owned).into_exp() + InvokeFunction(new_id, new_target, args_owned).into_exp() } else { exp } diff --git a/third_party/move/move-model/src/pureness_checker.rs b/third_party/move/move-model/src/pureness_checker.rs index 402090f9da8fc..6ed7011ec1923 100644 --- a/third_party/move/move-model/src/pureness_checker.rs +++ b/third_party/move/move-model/src/pureness_checker.rs @@ -56,7 +56,7 @@ impl FunctionPurenessChecker where F: FnMut(NodeId, &str, &[(QualifiedId, NodeId)]), { - /// Creates a new checker. The given function is invoke with diagnostic information + /// Creates a new checker. The given function is invoked with diagnostic information /// if impurity is detected. It is up to this function whether an actual error is /// reported. pub fn new(mode: FunctionPurenessCheckerMode, impure_action: F) -> Self { diff --git a/third_party/move/move-model/src/sourcifier.rs b/third_party/move/move-model/src/sourcifier.rs index fb5e2754c9d7c..a4ab01420eb66 100644 --- a/third_party/move/move-model/src/sourcifier.rs +++ b/third_party/move/move-model/src/sourcifier.rs @@ -758,7 +758,7 @@ impl<'a> ExpSourcifier<'a> { emit!(self.wr(), " '{}", self.sym(*label)) } }), - Invoke(_, fun, args) => self.parenthesize(context_prio, Prio::Postfix, || { + InvokeFunction(_, fun, args) => self.parenthesize(context_prio, Prio::Postfix, || { self.print_exp(Prio::Postfix, false, fun); self.print_exp_list("(", ")", args); }), @@ -823,7 +823,7 @@ impl<'a> ExpSourcifier<'a> { self.print_exp_list("(", ")", args) }) }, - Operation::EarlyBind => self.parenthesize(context_prio, Prio::Postfix, || { + Operation::EarlyBindFunction => self.parenthesize(context_prio, Prio::Postfix, || { emit!(self.wr(), "earlybind"); self.print_node_inst(id); self.print_exp_list("(", ")", args) diff --git a/third_party/move/move-prover/boogie-backend/src/spec_translator.rs b/third_party/move/move-prover/boogie-backend/src/spec_translator.rs index d3157c01a7161..a20a942be52b9 100644 --- a/third_party/move/move-prover/boogie-backend/src/spec_translator.rs +++ b/third_party/move/move-prover/boogie-backend/src/spec_translator.rs @@ -686,8 +686,11 @@ impl<'env> SpecTranslator<'env> { self.set_writer_location(*node_id); self.translate_call(*node_id, oper, args); }, - ExpData::Invoke(node_id, ..) => { - self.error(&self.env.get_node_loc(*node_id), "Invoke not yet supported"); + ExpData::InvokeFunction(node_id, ..) => { + self.error( + &self.env.get_node_loc(*node_id), + "InvokeFunction not yet supported", + ); // TODO(LAMBDA) }, ExpData::Lambda(node_id, ..) => self.error( @@ -1020,7 +1023,7 @@ impl<'env> SpecTranslator<'env> { | Operation::Deref | Operation::MoveTo | Operation::MoveFrom - | Operation::EarlyBind + | Operation::EarlyBindFunction | Operation::Old => { self.env.error( &self.env.get_node_loc(node_id), diff --git a/third_party/move/move-vm/runtime/src/interpreter.rs b/third_party/move/move-vm/runtime/src/interpreter.rs index 407720c217fc4..aa2c5a68a8d70 100644 --- a/third_party/move/move-vm/runtime/src/interpreter.rs +++ b/third_party/move/move-vm/runtime/src/interpreter.rs @@ -1607,8 +1607,8 @@ impl Frame { // TODO(LAMBDA): implement closures Bytecode::LdFunction(..) | Bytecode::LdFunctionGeneric(..) - | Bytecode::Invoke(..) - | Bytecode::EarlyBind(..) => { + | Bytecode::InvokeFunction(..) + | Bytecode::EarlyBindFunction(..) => { return Err(PartialVMError::new(StatusCode::UNIMPLEMENTED_FEATURE) .with_message("closure opcodes in interpreter".to_owned())) }, @@ -1740,8 +1740,8 @@ impl Frame { // TODO: implement closures Bytecode::LdFunction(..) | Bytecode::LdFunctionGeneric(..) - | Bytecode::Invoke(..) - | Bytecode::EarlyBind(..) => { + | Bytecode::InvokeFunction(..) + | Bytecode::EarlyBindFunction(..) => { return Err(PartialVMError::new(StatusCode::UNIMPLEMENTED_FEATURE) .with_message("closure opcodes in interpreter".to_owned())) }, @@ -2345,8 +2345,8 @@ impl Frame { // TODO(LAMBDA): implement closures Bytecode::LdFunction(..) | Bytecode::LdFunctionGeneric(..) - | Bytecode::Invoke(..) - | Bytecode::EarlyBind(..) => { + | Bytecode::InvokeFunction(..) + | Bytecode::EarlyBindFunction(..) => { return Err(PartialVMError::new(StatusCode::UNIMPLEMENTED_FEATURE) .with_message("closure opcodes in interpreter".to_owned())) }, diff --git a/third_party/move/move-vm/test-utils/src/gas_schedule.rs b/third_party/move/move-vm/test-utils/src/gas_schedule.rs index be4683e92f7d1..a73b39a26b060 100644 --- a/third_party/move/move-vm/test-utils/src/gas_schedule.rs +++ b/third_party/move/move-vm/test-utils/src/gas_schedule.rs @@ -708,8 +708,11 @@ pub fn zero_cost_instruction_table() -> Vec<(Bytecode, GasCost)> { LdFunctionGeneric(FunctionInstantiationIndex::new(0)), GasCost::new(0, 0), ), - (Invoke(SignatureIndex::new(0)), GasCost::new(0, 0)), - (EarlyBind(SignatureIndex::new(0), 0u8), GasCost::new(0, 0)), + (InvokeFunction(SignatureIndex::new(0)), GasCost::new(0, 0)), + ( + EarlyBindFunction(SignatureIndex::new(0), 0u8), + GasCost::new(0, 0), + ), ] } @@ -891,9 +894,12 @@ pub fn bytecode_instruction_costs() -> Vec<(Bytecode, GasCost)> { LdFunctionGeneric(FunctionInstantiationIndex::new(0)), GasCost::new(1132, 1), ), - (Invoke(SignatureIndex::new(0)), GasCost::new(1132, 1)), ( - EarlyBind(SignatureIndex::new(0), 0u8), + InvokeFunction(SignatureIndex::new(0)), + GasCost::new(1132, 1), + ), + ( + EarlyBindFunction(SignatureIndex::new(0), 0u8), GasCost::new(1132, 1), ), ] diff --git a/third_party/move/tools/move-disassembler/src/disassembler.rs b/third_party/move/tools/move-disassembler/src/disassembler.rs index a0d9e15417156..f368e269e5d77 100644 --- a/third_party/move/tools/move-disassembler/src/disassembler.rs +++ b/third_party/move/tools/move-disassembler/src/disassembler.rs @@ -732,13 +732,13 @@ impl<'a> Disassembler<'a> { Self::format_ret_type(&type_rets) )) }, - Bytecode::Invoke(idx) => { + Bytecode::InvokeFunction(idx) => { let _signature = self.source_mapper.bytecode.signature_at(*idx); - Ok(format!("Invoke({})", idx)) + Ok(format!("InvokeFunction({})", idx)) }, - Bytecode::EarlyBind(idx, count) => { + Bytecode::EarlyBindFunction(idx, count) => { let _signature = self.source_mapper.bytecode.signature_at(*idx); - Ok(format!("EarlyBind({}, {})", idx, count)) + Ok(format!("EarlyBindFunction({}, {})", idx, count)) }, Bytecode::LdConst(idx) => {