Skip to content

Commit 0ebfa2f

Browse files
[vm][WIP] Type IDs
1 parent e3fb8b7 commit 0ebfa2f

File tree

102 files changed

+3564
-2733
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+3564
-2733
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

aptos-move/aptos-native-interface/src/builder.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ use aptos_gas_algebra::DynamicExpression;
99
use aptos_gas_schedule::{MiscGasParameters, NativeGasParameters};
1010
use aptos_types::on_chain_config::{Features, TimedFeatures};
1111
use move_vm_runtime::native_functions::{NativeContext, NativeFunction};
12-
use move_vm_types::{
13-
loaded_data::runtime_types::Type, natives::function::NativeResult, values::Value,
14-
};
12+
use move_vm_types::{natives::function::NativeResult, ty_interner::TypeId, values::Value};
1513
use smallvec::SmallVec;
1614
use std::{collections::VecDeque, sync::Arc};
1715

@@ -81,9 +79,9 @@ impl SafeNativeBuilder {
8179
/// allowing the client to use [`SafeNativeContext`] instead of Move VM's [`NativeContext`].
8280
pub fn make_native<F>(&self, native: F) -> NativeFunction
8381
where
84-
F: Fn(
82+
F: for<'a> Fn(
8583
&mut SafeNativeContext,
86-
Vec<Type>,
84+
&'a [TypeId],
8785
VecDeque<Value>,
8886
) -> SafeNativeResult<SmallVec<[Value; 1]>>
8987
+ Send
@@ -95,7 +93,7 @@ impl SafeNativeBuilder {
9593

9694
let enable_incremental_gas_charging = self.enable_incremental_gas_charging;
9795

98-
let closure = move |context: &mut NativeContext, ty_args, args| {
96+
let closure = move |context: &mut NativeContext, ty_args: &[TypeId], args| {
9997
use SafeNativeError::*;
10098

10199
let mut context = SafeNativeContext {
@@ -175,9 +173,9 @@ impl SafeNativeBuilder {
175173
) -> impl Iterator<Item = (String, NativeFunction)> + 'a
176174
where
177175
'b: 'a,
178-
F: Fn(
176+
F: for<'c> Fn(
179177
&mut SafeNativeContext,
180-
Vec<Type>,
178+
&'c [TypeId],
181179
VecDeque<Value>,
182180
) -> SafeNativeResult<SmallVec<[Value; 1]>>
183181
+ Send

aptos-move/aptos-native-interface/src/errors.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
use move_binary_format::errors::PartialVMError;
55
use move_core_types::{identifier::Identifier, language_storage::ModuleId, vm_status::StatusCode};
6-
use move_vm_types::{loaded_data::runtime_types::Type, values::Value};
6+
use move_vm_types::{ty_interner::TypeId, values::Value};
77
use smallvec::SmallVec;
88

99
/// Wraps [PartialVMError] to ensure it cannot be constructed via public constructor when we create
@@ -81,7 +81,7 @@ pub enum SafeNativeError {
8181
FunctionDispatch {
8282
module_name: ModuleId,
8383
func_name: Identifier,
84-
ty_args: Vec<Type>,
84+
ty_args: Vec<TypeId>,
8585
args: SmallVec<[Value; 1]>,
8686
},
8787

aptos-move/aptos-native-interface/src/native.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44
use crate::{context::SafeNativeContext, errors::SafeNativeResult};
5-
use move_vm_types::{loaded_data::runtime_types::Type, values::Value};
5+
use move_vm_types::{ty_interner::TypeId, values::Value};
66
use smallvec::SmallVec;
77
use std::collections::VecDeque;
88

@@ -12,6 +12,6 @@ use std::collections::VecDeque;
1212
/// it can be used in the VM.
1313
pub type RawSafeNative = fn(
1414
&mut SafeNativeContext,
15-
Vec<Type>,
15+
&[TypeId],
1616
VecDeque<Value>,
1717
) -> SafeNativeResult<SmallVec<[Value; 1]>>;

aptos-move/aptos-vm-profiling/src/bins/run_move.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ use move_vm_runtime::{
2424
};
2525
use move_vm_test_utils::InMemoryStorage;
2626
use move_vm_types::{
27-
gas::UnmeteredGasMeter, loaded_data::runtime_types::Type, natives::function::NativeResult,
28-
pop_arg, values::Value,
27+
gas::UnmeteredGasMeter, natives::function::NativeResult, pop_arg, ty_interner::TypeId,
28+
values::Value,
2929
};
3030
use smallvec::smallvec;
3131
use std::{collections::VecDeque, env, fs, sync::Arc};
@@ -37,7 +37,7 @@ enum Entrypoint {
3737
}
3838

3939
fn make_native_create_signer() -> NativeFunction {
40-
Arc::new(|_context, ty_args: Vec<Type>, mut args: VecDeque<Value>| {
40+
Arc::new(|_context, ty_args: &[TypeId], mut args: VecDeque<Value>| {
4141
assert!(ty_args.is_empty());
4242
assert_eq!(args.len(), 1);
4343

0 commit comments

Comments
 (0)