Example #1
0
        private object GetPropertySlow(int index, ref DictionaryCacheSlot cacheSlot)
        {
            if (_store != null)
                return _value.GetPropertySlow(index, ref cacheSlot);

            #if TRACE_SPECULATION
            if (_store == null)
                Trace.WriteLine("Dictionary cache miss");
            #endif
            return _value.GetProperty(index);
        }
Example #2
0
        private object GetPropertySlow(JintRuntime runtime, int index, ref DictionaryCacheSlot cacheSlot)
        {
            if (_store != null)
            {
                return ((JsObject)_value).GetPropertySlow(index, ref cacheSlot);
            }

            #if TRACE_SPECULATION
            Trace.WriteLine("Dictionary cache miss");
            #endif
            return runtime.GetMemberByIndex(_value, index);
        }
Example #3
0
        public object GetProperty(int index, ref DictionaryCacheSlot cacheSlot)
        {
            if (_store != null && cacheSlot.Schema == _store.Schema)
            {
            #if TRACE_SPECULATION
                // Trace.WriteLine("Dictionary cache hit");
            #endif
                return _store.GetOwnPropertyRawUnchecked(cacheSlot.Index);
            }

            return GetPropertySlow(index, ref cacheSlot);
        }
Example #4
0
 public void SetProperty(int index, object value, ref DictionaryCacheSlot cacheSlot)
 {
     if (_store != null && cacheSlot.Schema == _store.Schema)
     {
     #if TRACE_SPECULATION
         // Trace.WriteLine("Dictionary cache hit");
     #endif
         _store.SetPropertyValueUnchecked(cacheSlot.Index, value);
     }
     else
     {
         SetPropertySlow(index, value, ref cacheSlot);
     }
 }
Example #5
0
 private void SetPropertySlow(int index, object value, ref DictionaryCacheSlot cacheSlot)
 {
     if (_store != null)
     {
         _value.SetPropertySlow(index, value, ref cacheSlot);
     }
     else
     {
     #if TRACE_SPECULATION
         if (_store == null)
             Trace.WriteLine("Dictionary cache miss");
     #endif
         _value.SetProperty(index, value);
     }
 }
Example #6
0
 private void SetPropertySlow(int index, object value, ref DictionaryCacheSlot cacheSlot)
 {
     if (_store != null)
     {
         if (cacheSlot.Schema == _store.Schema)
         {
     #if TRACE_SPECULATION
             // Trace.WriteLine("Dictionary cache hit");
     #endif
             _store.SetPropertyValueUnchecked(cacheSlot.Index, value);
         }
         else
         {
             ((JsObject)_value).SetPropertySlow(index, value, ref cacheSlot);
         }
     }
     else
     {
     #if TRACE_SPECULATION
         Trace.WriteLine("Dictionary cache miss");
     #endif
         JintRuntime.SetMemberByIndex(_value, index, value);
     }
 }
Example #7
0
        private object GetPropertyRaw(int index, ref DictionaryCacheSlot cacheSlot)
        {
            if (index == Id.prototype)
            {
                object value = GetOwnPropertyRaw(index);
                if (value != null)
                    return value;

                if (IsPrototypeNull)
                    return JsNull.Instance;

                return Prototype;
            }

            if (index == Id.__proto__)
            {
                if (IsPrototypeNull)
                    return JsNull.Instance;

                return Prototype;
            }

            if (PropertyStore != null)
            {
                if (_dictionaryPropertyStore != null)
                {
                    object result = _dictionaryPropertyStore.GetOwnPropertyRaw(index, ref cacheSlot);
                    if (result != null)
                        return result;
                }
                else
                {
                    object result = PropertyStore.GetOwnPropertyRaw(index);
                    if (result != null)
                        return result;
                }
            }

            var @object = Prototype;

            while ([email protected])
            {
                object result = @object.GetOwnPropertyRaw(index);
                if (result != null)
                    return result;

                @object = @object.Prototype;
            }

            return null;
        }
Example #8
0
        internal void SetPropertySlow(int index, object value, ref DictionaryCacheSlot cacheSlot)
        {
            // CLR objects have their own rules concerning how and when a
            // property is set.

            if (IsClr && _dictionaryPropertyStore == null)
            {
                PropertyStore.SetPropertyValue(index, value);
                return;
            }

            // If we have this property, either set it through the accessor
            // or directly on the property store.

            object currentValue = null;

            if (PropertyStore != null)
            {
                if (_dictionaryPropertyStore != null)
                    currentValue = _dictionaryPropertyStore.GetOwnPropertyRaw(index, ref cacheSlot);
                else
                    currentValue = PropertyStore.GetOwnPropertyRaw(index);
            }

            if (currentValue != null)
            {
                var accessor = currentValue as PropertyAccessor;
                if (accessor != null)
                {
                    // Cache slots are disabled for accessors. The thinking here
                    // is that accessors are rare, and this prevents us from
                    // having to do a get in the fast path.
                    cacheSlot = new DictionaryCacheSlot();
                    accessor.SetValue(this, value);
                }
                else
                {
                    PropertyStore.SetPropertyValue(index, value);
                }
                return;
            }

            // Check whether the prototype has an accessor.

            if (!IsPrototypeNull)
            {
                currentValue = Prototype.GetPropertyRaw(index);
                var accessor = currentValue as PropertyAccessor;
                if (accessor != null)
                {
                    accessor.SetValue(this, value);
                    return;
                }
            }

            // Otherwise, we're setting a new property.

            DefineProperty(index, value, PropertyAttributes.None);
        }
Example #9
0
        internal object GetPropertySlow(int index, ref DictionaryCacheSlot cacheSlot)
        {
            object value = GetPropertyRaw(index, ref cacheSlot);

            if (value == null)
                return ResolveUndefined(index);

            return ResolvePropertyValue(value);
        }
Example #10
0
 public void SetProperty(int index, object value, ref DictionaryCacheSlot cacheSlot)
 {
     if (cacheSlot.Schema != null && _dictionaryPropertyStore.Schema == cacheSlot.Schema)
         _dictionaryPropertyStore.SetPropertyValueUnchecked(cacheSlot.Index, value);
     else
         SetPropertySlow(index, value, ref cacheSlot);
 }
Example #11
0
        public object GetProperty(int index, ref DictionaryCacheSlot cacheSlot)
        {
            if (cacheSlot.Schema != null && _dictionaryPropertyStore.Schema == cacheSlot.Schema)
                return _dictionaryPropertyStore.GetOwnPropertyRawUnchecked(cacheSlot.Index);

            return GetPropertySlow(index, ref cacheSlot);
        }
Example #12
0
        public object GetOwnPropertyRaw(int index, ref DictionaryCacheSlot cacheSlot)
        {
            int offset = Schema.GetOffset(index);
            if (offset < 0)
                return null;

            cacheSlot = new DictionaryCacheSlot(Schema, offset);

            return _values[offset];
        }