Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 'use strict'; | 5 'use strict'; |
| 6 | 6 |
| 7 // This file relies on the fact that the following declaration has been made | 7 // This file relies on the fact that the following declaration has been made |
| 8 // in runtime.js: | 8 // in runtime.js: |
| 9 // var $Array = global.Array; | 9 // var $Array = global.Array; |
| 10 | 10 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 51 | 51 |
| 52 var stepping = DEBUG_IS_ACTIVE && %DebugCallbackSupportsStepping(f); | 52 var stepping = DEBUG_IS_ACTIVE && %DebugCallbackSupportsStepping(f); |
| 53 for (var i = 0; i < length; i++) { | 53 for (var i = 0; i < length; i++) { |
| 54 var element = this[i]; | 54 var element = this[i]; |
| 55 // Prepare break slots for debugger step in. | 55 // Prepare break slots for debugger step in. |
| 56 if (stepping) %DebugPrepareStepInIfStepping(f); | 56 if (stepping) %DebugPrepareStepInIfStepping(f); |
| 57 var new_receiver = needs_wrapper ? ToObject(receiver) : receiver; | 57 var new_receiver = needs_wrapper ? ToObject(receiver) : receiver; |
| 58 %_CallFunction(new_receiver, TO_OBJECT_INLINE(element), i, this, f); | 58 %_CallFunction(new_receiver, TO_OBJECT_INLINE(element), i, this, f); |
| 59 } | 59 } |
| 60 } | 60 } |
| 61 | |
| 62 | |
| 63 // ES6 draft 10-14-2014, section 22.1.3.6 | |
| 64 function NAMEFill(value /* [, start [, end ] ] */) { // length == 1 | |
| 65 CHECK_OBJECT_COERCIBLE(this, "NAME.prototype.fill"); | |
| 66 | |
| 67 var array = ToObject(this); | |
|
wingo
2014/11/12 09:29:56
Need a check that the object is indeed a typed arr
aperez
2014/11/13 16:34:36
well, CHECK_OBJECT_COERCIBLE() just checks that th
wingo
2014/11/14 14:27:50
Please see http://people.mozilla.org/~jorendorff/e
| |
| 68 var length = ToLength(array.length); | |
|
wingo
2014/11/12 09:29:56
Need to get the array's "length" internal slot, no
aperez
2014/11/13 16:34:36
The spec, in step 3 reads:
3. Let lenVal be Get
| |
| 69 | |
| 70 var i = 0; | |
| 71 var end = length; | |
| 72 | |
| 73 if (%_ArgumentsLength() > 1) { | |
| 74 i = %_Arguments(1); | |
| 75 i = IS_UNDEFINED(i) ? 0 : TO_INTEGER(i); | |
|
wingo
2014/11/12 09:29:56
I think that here we need i = TO_INTEGER(i) in all
aperez
2014/11/13 16:34:36
Well, according to the spec, the first step of ToI
| |
| 76 if (%_ArgumentsLength() > 2) { | |
| 77 end = %_Arguments(2); | |
| 78 end = IS_UNDEFINED(end) ? length : TO_INTEGER(end); | |
|
wingo
2014/11/12 09:29:56
Very strangely, this logic is correct for "end" bu
aperez
2014/11/13 16:34:36
For the case of end==undefined we want to take the
| |
| 79 } | |
| 80 } | |
| 81 | |
| 82 if (i < 0) { | |
| 83 i += length; | |
| 84 if (i < 0) i = 0; | |
| 85 } else { | |
| 86 if (i > length) i = length; | |
| 87 } | |
| 88 | |
| 89 if (end < 0) { | |
| 90 end += length; | |
| 91 if (end < 0) end = 0; | |
| 92 } else { | |
| 93 if (end > length) end = length; | |
| 94 } | |
| 95 | |
| 96 for (; i < end; i++) | |
| 97 array[i] = value; | |
| 98 return array; | |
| 99 } | |
| 61 endmacro | 100 endmacro |
| 62 | 101 |
| 63 TYPED_ARRAYS(TYPED_ARRAY_HARMONY_ADDITIONS) | 102 TYPED_ARRAYS(TYPED_ARRAY_HARMONY_ADDITIONS) |
| 64 | 103 |
| 65 | 104 |
| 66 function HarmonyTypedArrayExtendPrototypes() { | 105 function HarmonyTypedArrayExtendPrototypes() { |
| 67 macro EXTEND_TYPED_ARRAY(ARRAY_ID, NAME, ELEMENT_SIZE) | 106 macro EXTEND_TYPED_ARRAY(ARRAY_ID, NAME, ELEMENT_SIZE) |
| 68 %CheckIsBootstrapping(); | 107 %CheckIsBootstrapping(); |
| 69 | 108 |
| 70 // Set up non-enumerable functions on the prototype object. | 109 // Set up non-enumerable functions on the prototype object. |
| 71 InstallFunctions(global.NAME.prototype, DONT_ENUM, $Array( | 110 InstallFunctions(global.NAME.prototype, DONT_ENUM, $Array( |
|
wingo
2014/11/12 09:29:56
Both of these should be DONT_WRITE and DONT_DELETE
aperez
2014/11/13 16:34:36
Acknowledged.
| |
| 72 "forEach", NAMEForEach | 111 "forEach", NAMEForEach, |
| 112 "fill", NAMEFill | |
| 73 )); | 113 )); |
| 74 endmacro | 114 endmacro |
| 75 | 115 |
| 76 TYPED_ARRAYS(EXTEND_TYPED_ARRAY) | 116 TYPED_ARRAYS(EXTEND_TYPED_ARRAY) |
| 77 } | 117 } |
| 78 | 118 |
| 79 HarmonyTypedArrayExtendPrototypes(); | 119 HarmonyTypedArrayExtendPrototypes(); |
| OLD | NEW |