Skip to content

Commit

Permalink
more timers
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonwilliams committed May 31, 2020
1 parent 580210f commit 5b51ed0
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions boa/src/builtins/value/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ impl ValueData {
///
/// A copy of the Property is returned.
pub fn get_property(&self, field: &str) -> Option<Property> {
let _timer = BoaProfiler::global().start_event("Value::get_property", "value");
// Spidermonkey has its own GetLengthProperty: https://searchfox.org/mozilla-central/source/js/src/vm/Interpreter-inl.h#154
// This is only for primitive strings, String() objects have their lengths calculated in string.rs
if self.is_string() && field == "length" {
Expand Down Expand Up @@ -444,6 +445,7 @@ impl ValueData {
writable: Option<bool>,
configurable: Option<bool>,
) {
let _timer = BoaProfiler::global().start_event("Value::update_property", "value");
let obj: Option<Object> = match self {
Self::Object(ref obj) => Some(obj.borrow_mut().deref_mut().clone()),
_ => None,
Expand All @@ -464,6 +466,7 @@ impl ValueData {
///
/// Returns a copy of the Property.
pub fn get_internal_slot(&self, field: &str) -> Value {
let _timer = BoaProfiler::global().start_event("Value::get_internal_slot", "value");
let obj: Object = match *self {
Self::Object(ref obj) => {
let hash = obj.clone();
Expand All @@ -489,7 +492,7 @@ impl ValueData {
where
F: Into<Value>,
{
let _timer = BoaProfiler::global().start_event("get_field", "value");
let _timer = BoaProfiler::global().start_event("Value::get_field", "value");
match *field.into() {
// Our field will either be a String or a Symbol
Self::String(ref s) => {
Expand Down Expand Up @@ -588,7 +591,7 @@ impl ValueData {

/// Check to see if the Value has the field, mainly used by environment records
pub fn has_field(&self, field: &str) -> bool {
let _timer = BoaProfiler::global().start_event("has_field", "value");
let _timer = BoaProfiler::global().start_event("Value::has_field", "value");
self.get_property(field).is_some()
}

Expand All @@ -599,7 +602,7 @@ impl ValueData {
F: Into<Value>,
V: Into<Value>,
{
let _timer = BoaProfiler::global().start_event("set_field", "value");
let _timer = BoaProfiler::global().start_event("Value::set_field", "value");
let field = field.into();
let val = val.into();

Expand Down Expand Up @@ -629,7 +632,7 @@ impl ValueData {

/// Set the private field in the value
pub fn set_internal_slot(&self, field: &str, val: Value) -> Value {
let _timer = BoaProfiler::global().start_event("set_internal_slot", "exec");
let _timer = BoaProfiler::global().start_event("Value::set_internal_slot", "exec");
if let Self::Object(ref obj) = *self {
obj.borrow_mut()
.internal_slots
Expand Down Expand Up @@ -769,6 +772,7 @@ impl ValueData {
///
/// https://tc39.es/ecma262/#sec-typeof-operator
pub fn get_type(&self) -> &'static str {
let _timer = BoaProfiler::global().start_event("Value::get_type", "value");
match *self {
Self::Rational(_) | Self::Integer(_) => "number",
Self::String(_) => "string",
Expand Down

0 comments on commit 5b51ed0

Please sign in to comment.