summaryrefslogtreecommitdiff
path: root/ops/optimizer.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2022-12-15 16:26:10 +0100
committerGitHub <noreply@github.com>2022-12-15 15:26:10 +0000
commit585ec1218f8cdc191f2e733beb2e6c7a230ac85c (patch)
tree8a0e5d88f2390890121a6083a39c833af21ea5d1 /ops/optimizer.rs
parent0d4e4af7acf82c1365999a7281910daa05f0e982 (diff)
Revert "feat(ops): Fast zero copy string arguments (#16777)" (#17063)
This reverts commit 9b2b8df927ac23cfa99016a684179f2a3198ba2e. Closes https://github.com/dsherret/ts-morph/issues/1372 Closes https://github.com/denoland/deno/issues/16979
Diffstat (limited to 'ops/optimizer.rs')
-rw-r--r--ops/optimizer.rs90
1 files changed, 0 insertions, 90 deletions
diff --git a/ops/optimizer.rs b/ops/optimizer.rs
index 99de4b424..2d68a296f 100644
--- a/ops/optimizer.rs
+++ b/ops/optimizer.rs
@@ -20,19 +20,11 @@ pub(crate) enum BailoutReason {
}
#[derive(Debug, PartialEq)]
-enum StringType {
- Cow,
- Ref,
- Owned,
-}
-
-#[derive(Debug, PartialEq)]
enum TransformKind {
// serde_v8::Value
V8Value,
SliceU32(bool),
SliceU8(bool),
- SeqOneByteString(StringType),
PtrU8,
WasmMemory,
}
@@ -59,13 +51,6 @@ impl Transform {
}
}
- fn seq_one_byte_string(index: usize, is_ref: StringType) -> Self {
- Transform {
- kind: TransformKind::SeqOneByteString(is_ref),
- index,
- }
- }
-
fn wasm_memory(index: usize) -> Self {
Transform {
kind: TransformKind::WasmMemory,
@@ -147,21 +132,6 @@ impl Transform {
};
})
}
- // &str
- TransformKind::SeqOneByteString(str_ty) => {
- *ty = parse_quote! { *const #core::v8::fast_api::FastApiOneByteString };
- match str_ty {
- StringType::Ref => q!(Vars { var: &ident }, {
- let var = unsafe { &*var }.as_str();
- }),
- StringType::Cow => q!(Vars { var: &ident }, {
- let var = ::std::borrow::Cow::Borrowed(unsafe { &*var }.as_str());
- }),
- StringType::Owned => q!(Vars { var: &ident }, {
- let var = unsafe { &*var }.as_str().to_owned();
- }),
- }
- }
TransformKind::WasmMemory => {
// Note: `ty` is correctly set to __opts by the fast call tier.
q!(Vars { var: &ident, core }, {
@@ -228,7 +198,6 @@ pub(crate) enum FastValue {
V8Value,
Uint8Array,
Uint32Array,
- SeqOneByteString,
}
impl Default for FastValue {
@@ -581,58 +550,10 @@ impl Optimizer {
}
}
}
- // Cow<'_, str>
- PathSegment {
- ident, arguments, ..
- } if ident == "Cow" => {
- if let PathArguments::AngleBracketed(
- AngleBracketedGenericArguments { args, .. },
- ) = arguments
- {
- assert_eq!(args.len(), 2);
-
- let ty = &args[1];
- match ty {
- GenericArgument::Type(Type::Path(TypePath {
- path: Path { segments, .. },
- ..
- })) => {
- let segment = single_segment(segments)?;
- match segment {
- PathSegment { ident, .. } if ident == "str" => {
- self.fast_parameters.push(FastValue::SeqOneByteString);
- assert!(self
- .transforms
- .insert(
- index,
- Transform::seq_one_byte_string(
- index,
- StringType::Cow
- )
- )
- .is_none());
- }
- _ => return Err(BailoutReason::FastUnsupportedParamType),
- }
- }
- _ => return Err(BailoutReason::FastUnsupportedParamType),
- }
- }
- }
// Is `T` a fast scalar?
PathSegment { ident, .. } => {
if let Some(val) = get_fast_scalar(ident.to_string().as_str()) {
self.fast_parameters.push(val);
- } else if ident == "String" {
- // Is `T` an owned String?
- self.fast_parameters.push(FastValue::SeqOneByteString);
- assert!(self
- .transforms
- .insert(
- index,
- Transform::seq_one_byte_string(index, StringType::Owned)
- )
- .is_none());
} else {
return Err(BailoutReason::FastUnsupportedParamType);
}
@@ -655,17 +576,6 @@ impl Optimizer {
{
self.has_ref_opstate = true;
}
- // Is `T` a str?
- PathSegment { ident, .. } if ident == "str" => {
- self.fast_parameters.push(FastValue::SeqOneByteString);
- assert!(self
- .transforms
- .insert(
- index,
- Transform::seq_one_byte_string(index, StringType::Ref)
- )
- .is_none());
- }
_ => return Err(BailoutReason::FastUnsupportedParamType),
}
}