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

Unified Diff: src/builtins.cc

Issue 2123263002: [builtins] Migrate SharedArrayBuffer.byteLength to C++. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@ArrayBufferGetByteLen
Patch Set: Minor typo fixes Created 4 years, 5 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 | « src/builtins.h ('k') | src/js/harmony-sharedarraybuffer.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/builtins.cc
diff --git a/src/builtins.cc b/src/builtins.cc
index 30e3b822dff8e8560485d05bca2abeb590956963..556082edf330bbd13f5e7a9b1ffea033e68d61e6 100644
--- a/src/builtins.cc
+++ b/src/builtins.cc
@@ -5627,6 +5627,14 @@ BUILTIN(ArrayBufferPrototypeGetByteLength) {
HandleScope scope(isolate);
CHECK_RECEIVER(JSArrayBuffer, array_buffer,
"get ArrayBuffer.prototype.byteLength");
+
+ if (array_buffer->is_shared()) {
+ THROW_NEW_ERROR_RETURN_FAILURE(
+ isolate, NewTypeError(MessageTemplate::kIncompatibleMethodReceiver,
+ isolate->factory()->NewStringFromAsciiChecked(
+ "get ArrayBuffer.prototype.byteLength"),
+ args.receiver()));
+ }
// TODO(franzih): According to the ES6 spec, we should throw a TypeError
// here if the JSArrayBuffer is detached.
return array_buffer->byte_length();
@@ -5640,6 +5648,20 @@ BUILTIN(ArrayBufferIsView) {
return isolate->heap()->ToBoolean(arg->IsJSArrayBufferView());
}
+// ES7 sharedmem 6.3.4.1 get SharedArrayBuffer.prototype.byteLength
+BUILTIN(SharedArrayBufferPrototypeGetByteLength) {
+ HandleScope scope(isolate);
+ CHECK_RECEIVER(JSArrayBuffer, array_buffer,
+ "get SharedArrayBuffer.prototype.byteLength");
+ if (!array_buffer->is_shared()) {
+ THROW_NEW_ERROR_RETURN_FAILURE(
+ isolate, NewTypeError(MessageTemplate::kIncompatibleMethodReceiver,
+ isolate->factory()->NewStringFromAsciiChecked(
+ "get SharedArrayBuffer.prototype.byteLength"),
+ args.receiver()));
+ }
+ return array_buffer->byte_length();
+}
// ES6 section 26.2.1.1 Proxy ( target, handler ) for the [[Call]] case.
BUILTIN(ProxyConstructor) {
« no previous file with comments | « src/builtins.h ('k') | src/js/harmony-sharedarraybuffer.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698