| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 (function(global, utils) { | 5 (function(global, utils) { |
| 6 | 6 |
| 7 "use strict"; | 7 "use strict"; |
| 8 | 8 |
| 9 %CheckIsBootstrapping(); | 9 %CheckIsBootstrapping(); |
| 10 | 10 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 if (fin < first) { | 63 if (fin < first) { |
| 64 fin = first; | 64 fin = first; |
| 65 } | 65 } |
| 66 var newLen = fin - first; | 66 var newLen = fin - first; |
| 67 var constructor = SpeciesConstructor(this, GlobalArrayBuffer, true); | 67 var constructor = SpeciesConstructor(this, GlobalArrayBuffer, true); |
| 68 var result = new constructor(newLen); | 68 var result = new constructor(newLen); |
| 69 if (!IS_ARRAYBUFFER(result)) { | 69 if (!IS_ARRAYBUFFER(result)) { |
| 70 throw MakeTypeError(kIncompatibleMethodReceiver, | 70 throw MakeTypeError(kIncompatibleMethodReceiver, |
| 71 'ArrayBuffer.prototype.slice', result); | 71 'ArrayBuffer.prototype.slice', result); |
| 72 } | 72 } |
| 73 // TODO(littledan): Check for a detached ArrayBuffer | 73 // Checks for detached source/target ArrayBuffers are done inside of |
| 74 // %ArrayBufferSliceImpl; the reordering of checks does not violate |
| 75 // the spec because all exceptions thrown are TypeErrors. |
| 74 if (result === this) { | 76 if (result === this) { |
| 75 throw MakeTypeError(kArrayBufferSpeciesThis); | 77 throw MakeTypeError(kArrayBufferSpeciesThis); |
| 76 } | 78 } |
| 77 if (%_ArrayBufferGetByteLength(result) < newLen) { | 79 if (%_ArrayBufferGetByteLength(result) < newLen) { |
| 78 throw MakeTypeError(kArrayBufferTooShort); | 80 throw MakeTypeError(kArrayBufferTooShort); |
| 79 } | 81 } |
| 80 | 82 |
| 81 %ArrayBufferSliceImpl(this, result, first, newLen); | 83 %ArrayBufferSliceImpl(this, result, first, newLen); |
| 82 return result; | 84 return result; |
| 83 } | 85 } |
| 84 | 86 |
| 85 utils.InstallGetter(GlobalArrayBuffer.prototype, "byteLength", | 87 utils.InstallGetter(GlobalArrayBuffer.prototype, "byteLength", |
| 86 ArrayBufferGetByteLen); | 88 ArrayBufferGetByteLen); |
| 87 | 89 |
| 88 utils.InstallFunctions(GlobalArrayBuffer.prototype, DONT_ENUM, [ | 90 utils.InstallFunctions(GlobalArrayBuffer.prototype, DONT_ENUM, [ |
| 89 "slice", ArrayBufferSlice | 91 "slice", ArrayBufferSlice |
| 90 ]); | 92 ]); |
| 91 | 93 |
| 92 }) | 94 }) |
| OLD | NEW |