Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(622)

Unified Diff: src/js/arraybuffer.js

Issue 1574903004: TypedArray and ArrayBuffer support for @@species (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Preserve old behavior Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/js/runtime.js » ('j') | src/js/runtime.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/js/arraybuffer.js
diff --git a/src/js/arraybuffer.js b/src/js/arraybuffer.js
index 1ee68ca291b0ccc6c6affc79af5c7bcc6b90c493..ddd3c2f3675fc75aa9cb9cb97a3fd3c4b6e3c043 100644
--- a/src/js/arraybuffer.js
+++ b/src/js/arraybuffer.js
@@ -15,11 +15,13 @@ var GlobalArrayBuffer = global.ArrayBuffer;
var MakeTypeError;
var MaxSimple;
var MinSimple;
+var SpeciesConstructor;
utils.Import(function(from) {
MakeTypeError = from.MakeTypeError;
MaxSimple = from.MaxSimple;
MinSimple = from.MinSimple;
+ SpeciesConstructor = from.SpeciesConstructor;
});
// -------------------------------------------------------------------
@@ -62,10 +64,20 @@ function ArrayBufferSlice(start, end) {
fin = first;
}
var newLen = fin - first;
- // TODO(dslomov): implement inheritance
- var result = new GlobalArrayBuffer(newLen);
+ var constructor = SpeciesConstructor(this, GlobalArrayBuffer, true);
+ var result = new constructor(newLen);
+ if (!IS_ARRAYBUFFER(result)) {
adamk 2016/01/12 00:11:00 Is this exercised in some test?
Dan Ehrenberg 2016/01/12 01:38:33 Test262, but that's not active yet so I wrote anot
+ throw MakeTypeError(kIncompatibleMethodReceiver,
+ 'ArrayBuffer.prototype.slice', result);
+ }
+ if (%_ArrayBufferGetByteLength(result) < newLen) {
adamk 2016/01/12 00:11:00 And this? Same question about most of these error
Dan Ehrenberg 2016/01/12 01:38:33 Oops, I forgot to add the file test/mjsunit/harmon
+ throw MakeTypeError(kArrayBufferTooShort);
+ }
+ if (result === this) {
adamk 2016/01/12 00:11:00 FWIW this check precedes the byte length check in
Dan Ehrenberg 2016/01/12 01:38:33 Was in test262, added an mjsunit test for it.
+ throw MakeTypeError(kArrayBufferSpeciesThis);
+ }
- %ArrayBufferSliceImpl(this, result, first);
+ %ArrayBufferSliceImpl(this, result, first, newLen);
return result;
}
« no previous file with comments | « no previous file | src/js/runtime.js » ('j') | src/js/runtime.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698