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

[Merged by Bors] - Optimize Get/SetPropertyByName #2608

Closed
wants to merge 2 commits 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
4 changes: 2 additions & 2 deletions boa_engine/src/value/mod.rs
Original file line number Diff line number Diff line change
@@ -21,9 +21,9 @@ use crate::{
Number,
},
error::JsNativeError,
js_string,
object::{JsObject, ObjectData},
property::{PropertyDescriptor, PropertyKey},
string::utf16,
symbol::JsSymbol,
Context, JsBigInt, JsResult, JsString,
};
@@ -526,7 +526,7 @@ impl JsValue {
JsObject::from_proto_and_data(prototype, ObjectData::string(string.clone()));
// Make sure the correct length is set on our new string object
object.insert_property(
js_string!("length"),
utf16!("length"),
PropertyDescriptor::builder()
.value(string.len())
.writable(false)
9 changes: 3 additions & 6 deletions boa_engine/src/vm/opcode/get/property.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{
property::PropertyKey,
vm::{opcode::Operation, ShouldExit},
Context, JsResult, JsString,
Context, JsResult,
};

/// `GetPropertyByName` implements the Opcode Operation for `Opcode::GetPropertyByName`
@@ -25,11 +25,8 @@ impl Operation for GetPropertyByName {
value.to_object(context)?
};

let key: PropertyKey = context
.interner()
.resolve_expect(context.vm.frame().code_block.names[index as usize].sym())
.into_common::<JsString>(false)
.into();
let name = context.vm.frame().code_block.names[index as usize];
let key: PropertyKey = context.interner().resolve_expect(name.sym()).utf16().into();
let result = object.__get__(&key, value, context)?;

context.vm.push(result);
6 changes: 1 addition & 5 deletions boa_engine/src/vm/opcode/set/property.rs
Original file line number Diff line number Diff line change
@@ -29,11 +29,7 @@ impl Operation for SetPropertyByName {
};

let name = context.vm.frame().code_block.names[index as usize];
let name: PropertyKey = context
.interner()
.resolve_expect(name.sym())
.into_common::<JsString>(false)
.into();
let name: PropertyKey = context.interner().resolve_expect(name.sym()).utf16().into();

//object.set(name, value.clone(), context.vm.frame().code.strict, context)?;
let succeeded = object.__set__(name.clone(), value.clone(), receiver, context)?;