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

Side by Side Diff: src/typedarray.js

Issue 1318043002: Native context: do not put public symbols and flags on the js builtins object. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix and rebase Created 5 years, 3 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 unified diff | Download patch
« no previous file with comments | « src/symbol.js ('k') | src/v8natives.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 // ------------------------------------------------------------------- 11 // -------------------------------------------------------------------
12 // Imports 12 // Imports
13 13
14 var GlobalArray = global.Array; 14 var GlobalArray = global.Array;
15 var GlobalArrayBuffer = global.ArrayBuffer; 15 var GlobalArrayBuffer = global.ArrayBuffer;
16 var GlobalDataView = global.DataView; 16 var GlobalDataView = global.DataView;
17 var GlobalObject = global.Object; 17 var GlobalObject = global.Object;
18 var iteratorSymbol = utils.ImportNow("iterator_symbol");
19 var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
18 20
19 macro TYPED_ARRAYS(FUNCTION) 21 macro TYPED_ARRAYS(FUNCTION)
20 // arrayIds below should be synchronized with Runtime_TypedArrayInitialize. 22 // arrayIds below should be synchronized with Runtime_TypedArrayInitialize.
21 FUNCTION(1, Uint8Array, 1) 23 FUNCTION(1, Uint8Array, 1)
22 FUNCTION(2, Int8Array, 1) 24 FUNCTION(2, Int8Array, 1)
23 FUNCTION(3, Uint16Array, 2) 25 FUNCTION(3, Uint16Array, 2)
24 FUNCTION(4, Int16Array, 2) 26 FUNCTION(4, Int16Array, 2)
25 FUNCTION(5, Uint32Array, 4) 27 FUNCTION(5, Uint32Array, 4)
26 FUNCTION(6, Int32Array, 4) 28 FUNCTION(6, Int32Array, 4)
27 FUNCTION(7, Float32Array, 4) 29 FUNCTION(7, Float32Array, 4)
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 // observable with getters, so instead, we call the function which 142 // observable with getters, so instead, we call the function which
141 // was already looked up, and wrap it in another iterable. The 143 // was already looked up, and wrap it in another iterable. The
142 // __proto__ of the new iterable is set to null to avoid any chance 144 // __proto__ of the new iterable is set to null to avoid any chance
143 // of modifications to Object.prototype being observable here. 145 // of modifications to Object.prototype being observable here.
144 var iterator = %_CallFunction(iterable, iteratorFn); 146 var iterator = %_CallFunction(iterable, iteratorFn);
145 var newIterable = { 147 var newIterable = {
146 __proto__: null 148 __proto__: null
147 }; 149 };
148 // TODO(littledan): Computed properties don't work yet in nosnap. 150 // TODO(littledan): Computed properties don't work yet in nosnap.
149 // Rephrase when they do. 151 // Rephrase when they do.
150 newIterable[symbolIterator] = function() { return iterator; } 152 newIterable[iteratorSymbol] = function() { return iterator; }
151 for (var value of newIterable) { 153 for (var value of newIterable) {
152 list.push(value); 154 list.push(value);
153 } 155 }
154 NAMEConstructByArrayLike(obj, list); 156 NAMEConstructByArrayLike(obj, list);
155 } 157 }
156 158
157 function NAMEConstructor(arg1, arg2, arg3) { 159 function NAMEConstructor(arg1, arg2, arg3) {
158 if (%_IsConstructCall()) { 160 if (%_IsConstructCall()) {
159 if (IS_ARRAYBUFFER(arg1) || IS_SHAREDARRAYBUFFER(arg1)) { 161 if (IS_ARRAYBUFFER(arg1) || IS_SHAREDARRAYBUFFER(arg1)) {
160 NAMEConstructByArrayBuffer(this, arg1, arg2, arg3); 162 NAMEConstructByArrayBuffer(this, arg1, arg2, arg3);
161 } else if (IS_NUMBER(arg1) || IS_STRING(arg1) || 163 } else if (IS_NUMBER(arg1) || IS_STRING(arg1) ||
162 IS_BOOLEAN(arg1) || IS_UNDEFINED(arg1)) { 164 IS_BOOLEAN(arg1) || IS_UNDEFINED(arg1)) {
163 NAMEConstructByLength(this, arg1); 165 NAMEConstructByLength(this, arg1);
164 } else { 166 } else {
165 var iteratorFn = arg1[symbolIterator]; 167 var iteratorFn = arg1[iteratorSymbol];
166 if (IS_UNDEFINED(iteratorFn) || iteratorFn === $arrayValues) { 168 if (IS_UNDEFINED(iteratorFn) || iteratorFn === $arrayValues) {
167 NAMEConstructByArrayLike(this, arg1); 169 NAMEConstructByArrayLike(this, arg1);
168 } else { 170 } else {
169 NAMEConstructByIterable(this, arg1, iteratorFn); 171 NAMEConstructByIterable(this, arg1, iteratorFn);
170 } 172 }
171 } 173 }
172 } else { 174 } else {
173 throw MakeTypeError(kConstructorNotFunction, "NAME") 175 throw MakeTypeError(kConstructorNotFunction, "NAME")
174 } 176 }
175 } 177 }
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 %AddNamedProperty(GlobalNAME.prototype, 363 %AddNamedProperty(GlobalNAME.prototype,
362 "BYTES_PER_ELEMENT", ELEMENT_SIZE, 364 "BYTES_PER_ELEMENT", ELEMENT_SIZE,
363 READ_ONLY | DONT_ENUM | DONT_DELETE); 365 READ_ONLY | DONT_ENUM | DONT_DELETE);
364 utils.InstallGetter(GlobalNAME.prototype, "buffer", NAME_GetBuffer); 366 utils.InstallGetter(GlobalNAME.prototype, "buffer", NAME_GetBuffer);
365 utils.InstallGetter(GlobalNAME.prototype, "byteOffset", NAME_GetByteOffset, 367 utils.InstallGetter(GlobalNAME.prototype, "byteOffset", NAME_GetByteOffset,
366 DONT_ENUM | DONT_DELETE); 368 DONT_ENUM | DONT_DELETE);
367 utils.InstallGetter(GlobalNAME.prototype, "byteLength", NAME_GetByteLength, 369 utils.InstallGetter(GlobalNAME.prototype, "byteLength", NAME_GetByteLength,
368 DONT_ENUM | DONT_DELETE); 370 DONT_ENUM | DONT_DELETE);
369 utils.InstallGetter(GlobalNAME.prototype, "length", NAME_GetLength, 371 utils.InstallGetter(GlobalNAME.prototype, "length", NAME_GetLength,
370 DONT_ENUM | DONT_DELETE); 372 DONT_ENUM | DONT_DELETE);
371 utils.InstallGetter(GlobalNAME.prototype, symbolToStringTag, 373 utils.InstallGetter(GlobalNAME.prototype, toStringTagSymbol,
372 TypedArrayGetToStringTag); 374 TypedArrayGetToStringTag);
373 utils.InstallFunctions(GlobalNAME.prototype, DONT_ENUM, [ 375 utils.InstallFunctions(GlobalNAME.prototype, DONT_ENUM, [
374 "subarray", NAMESubArray, 376 "subarray", NAMESubArray,
375 "set", TypedArraySet 377 "set", TypedArraySet
376 ]); 378 ]);
377 endmacro 379 endmacro
378 380
379 TYPED_ARRAYS(SETUP_TYPED_ARRAY) 381 TYPED_ARRAYS(SETUP_TYPED_ARRAY)
380 382
381 // --------------------------- DataView ----------------------------- 383 // --------------------------- DataView -----------------------------
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 469
468 DATA_VIEW_TYPES(DATA_VIEW_GETTER_SETTER) 470 DATA_VIEW_TYPES(DATA_VIEW_GETTER_SETTER)
469 471
470 // Setup the DataView constructor. 472 // Setup the DataView constructor.
471 %SetCode(GlobalDataView, DataViewConstructor); 473 %SetCode(GlobalDataView, DataViewConstructor);
472 %FunctionSetPrototype(GlobalDataView, new GlobalObject); 474 %FunctionSetPrototype(GlobalDataView, new GlobalObject);
473 475
474 // Set up constructor property on the DataView prototype. 476 // Set up constructor property on the DataView prototype.
475 %AddNamedProperty(GlobalDataView.prototype, "constructor", GlobalDataView, 477 %AddNamedProperty(GlobalDataView.prototype, "constructor", GlobalDataView,
476 DONT_ENUM); 478 DONT_ENUM);
477 %AddNamedProperty(GlobalDataView.prototype, symbolToStringTag, "DataView", 479 %AddNamedProperty(GlobalDataView.prototype, toStringTagSymbol, "DataView",
478 READ_ONLY|DONT_ENUM); 480 READ_ONLY|DONT_ENUM);
479 481
480 utils.InstallGetter(GlobalDataView.prototype, "buffer", DataViewGetBufferJS); 482 utils.InstallGetter(GlobalDataView.prototype, "buffer", DataViewGetBufferJS);
481 utils.InstallGetter(GlobalDataView.prototype, "byteOffset", 483 utils.InstallGetter(GlobalDataView.prototype, "byteOffset",
482 DataViewGetByteOffset); 484 DataViewGetByteOffset);
483 utils.InstallGetter(GlobalDataView.prototype, "byteLength", 485 utils.InstallGetter(GlobalDataView.prototype, "byteLength",
484 DataViewGetByteLength); 486 DataViewGetByteLength);
485 487
486 utils.InstallFunctions(GlobalDataView.prototype, DONT_ENUM, [ 488 utils.InstallFunctions(GlobalDataView.prototype, DONT_ENUM, [
487 "getInt8", DataViewGetInt8JS, 489 "getInt8", DataViewGetInt8JS,
(...skipping 15 matching lines...) Expand all
503 "setUint32", DataViewSetUint32JS, 505 "setUint32", DataViewSetUint32JS,
504 506
505 "getFloat32", DataViewGetFloat32JS, 507 "getFloat32", DataViewGetFloat32JS,
506 "setFloat32", DataViewSetFloat32JS, 508 "setFloat32", DataViewSetFloat32JS,
507 509
508 "getFloat64", DataViewGetFloat64JS, 510 "getFloat64", DataViewGetFloat64JS,
509 "setFloat64", DataViewSetFloat64JS 511 "setFloat64", DataViewSetFloat64JS
510 ]); 512 ]);
511 513
512 }) 514 })
OLDNEW
« no previous file with comments | « src/symbol.js ('k') | src/v8natives.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698