<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>145358</bug_id>
          
          <creation_ts>2015-05-24 10:39:33 -0700</creation_ts>
          <short_desc>[JSC] indexed property doesn&apos;t work well</short_desc>
          <delta_ts>2015-08-11 23:57:32 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>JavaScriptCore</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          <dependson>145360</dependson>
    
    <dependson>144252</dependson>
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Yusuke Suzuki">ysuzuki</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>benjamin</cc>
    
    <cc>darin</cc>
    
    <cc>fpizlo</cc>
    
    <cc>ggaren</cc>
    
    <cc>joepeck</cc>
    
    <cc>rniwa</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1097153</commentid>
    <comment_count>0</comment_count>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2015-05-24 10:39:33 -0700</bug_when>
    <thetext>STEP TO REPRODUCE:

var object = {
    length: 5,
    0: 0,
    get 1() {
        return 1;
    },
    set 1(value) {
        print(value);
        throw new Error(2);
    },
    2: 2,
    3: 3,
};

print(JSON.stringify(Object.getOwnPropertyDescriptor(object, 1)));

EXPECTED:
&apos;{&quot;enumerable&quot;:true,&quot;configurable&quot;:true}&apos;

ACTUAL:
undefined</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1097156</commentid>
    <comment_count>1</comment_count>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2015-05-24 10:47:06 -0700</bug_when>
    <thetext>The following issue might be related to this issue.

var object = {
    get 2() {
        return 1;
    },
    set 2(value) {
        throw new Error(2);
    },
    2: 2,  // Throw new Error(2)
};

Is this expected behavior?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1097165</commentid>
    <comment_count>2</comment_count>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2015-05-24 11:38:42 -0700</bug_when>
    <thetext>The following code will fail with assertions.

(function () {
    Object.defineProperty(Object.prototype, 0, {
        get() {
            print(&quot;Get&quot;);
        },
        set() {
            print(&quot;Set&quot;);
        }
    });
    var object = {
        length: 5,
        0: 0,
        get 1() {
            return 1;
        },
        set 1(value) {
            throw new Error(2);
        },
        2: 2,
        3: 3,
    };
}());</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1097168</commentid>
    <comment_count>3</comment_count>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2015-05-24 12:29:22 -0700</bug_when>
    <thetext>The following should throw an error, but don&apos;t.

Object.defineProperty(Object.prototype, 2, {
    set: function () {
        throw new Error(&quot;out&quot;);
    }
}); 
var obj = {};
obj[2] = &apos;hello&apos;;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1097169</commentid>
    <comment_count>4</comment_count>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2015-05-24 12:30:23 -0700</bug_when>
    <thetext>Hm, it seems that current JSC has serious issues about indexed properties.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1097174</commentid>
    <comment_count>5</comment_count>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2015-05-24 12:35:10 -0700</bug_when>
    <thetext>(In reply to comment #1)
&gt; The following issue might be related to this issue.
&gt; 
&gt; var object = {
&gt;     get 2() {
&gt;         return 1;
&gt;     },
&gt;     set 2(value) {
&gt;         throw new Error(2);
&gt;     },
&gt;     2: 2,  // Throw new Error(2)
&gt; };
&gt; 
&gt; Is this expected behavior?

https://bugs.webkit.org/show_bug.cgi?id=145360 fixes it.
But the other 3 issues remain.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1097175</commentid>
    <comment_count>6</comment_count>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2015-05-24 12:37:38 -0700</bug_when>
    <thetext>Make the first step :D
https://bugs.webkit.org/show_bug.cgi?id=145360

And change it to meta bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1100769</commentid>
    <comment_count>7</comment_count>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2015-06-09 13:14:13 -0700</bug_when>
    <thetext>After investigating the issue, I found that storage type is accidentally changed.
I&apos;ll investigate more to fix it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1116910</commentid>
    <comment_count>8</comment_count>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2015-08-11 23:48:06 -0700</bug_when>
    <thetext>https://bugs.webkit.org/show_bug.cgi?id=144252 this also fixes the one of the issue listed in this bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1116911</commentid>
    <comment_count>9</comment_count>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2015-08-11 23:57:32 -0700</bug_when>
    <thetext>(In reply to comment #2)
&gt; The following code will fail with assertions.
&gt; 
&gt; (function () {
&gt;     Object.defineProperty(Object.prototype, 0, {
&gt;         get() {
&gt;             print(&quot;Get&quot;);
&gt;         },
&gt;         set() {
&gt;             print(&quot;Set&quot;);
&gt;         }
&gt;     });
&gt;     var object = {
&gt;         length: 5,
&gt;         0: 0,
&gt;         get 1() {
&gt;             return 1;
&gt;         },
&gt;         set 1(value) {
&gt;             throw new Error(2);
&gt;         },
&gt;         2: 2,
&gt;         3: 3,
&gt;     };
&gt; }());

The remaining issue is this.

1. JSObject has 2 storage, vector and map. And map has 2 types, non-sparse and sparse (dictionary mode)
2. If the JSObject is the dictionary mode, there&apos;s no vector
3. If the map of the JSObject is non-sparse, there may be the vector. But the ranges of these storages are not overlapped.
4. And JSObject stores the accessor into the map that is not marked as the sparse.
5. But in the other place (like JSArray), they assume that the map does not contain the accessors if the map is not marked as the sparse.

The simplest solution is, &quot;when storing the indexed accessor, always make the object the dictionary mode&quot;. But one concern is the performance regression.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>