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

Side by Side Diff: src/arraybuffer.js

Issue 1394303003: Revert of Use simple/fast macro version of MinMax in JS (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 2 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/array.js ('k') | src/harmony-array.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 GlobalArrayBuffer = global.ArrayBuffer; 14 var GlobalArrayBuffer = global.ArrayBuffer;
15 var GlobalObject = global.Object; 15 var GlobalObject = global.Object;
16 var MathMax;
17 var MathMin;
16 var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol"); 18 var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
17 19
20 utils.Import(function(from) {
21 MathMax = from.MathMax;
22 MathMin = from.MathMin;
23 });
24
18 // ------------------------------------------------------------------- 25 // -------------------------------------------------------------------
19 26
20 function ArrayBufferConstructor(length) { // length = 1 27 function ArrayBufferConstructor(length) { // length = 1
21 if (%_IsConstructCall()) { 28 if (%_IsConstructCall()) {
22 var byteLength = $toPositiveInteger(length, kInvalidArrayBufferLength); 29 var byteLength = $toPositiveInteger(length, kInvalidArrayBufferLength);
23 %ArrayBufferInitialize(this, byteLength, kNotShared); 30 %ArrayBufferInitialize(this, byteLength, kNotShared);
24 } else { 31 } else {
25 throw MakeTypeError(kConstructorNotFunction, "ArrayBuffer"); 32 throw MakeTypeError(kConstructorNotFunction, "ArrayBuffer");
26 } 33 }
27 } 34 }
(...skipping 13 matching lines...) Expand all
41 'ArrayBuffer.prototype.slice', this); 48 'ArrayBuffer.prototype.slice', this);
42 } 49 }
43 50
44 var relativeStart = TO_INTEGER(start); 51 var relativeStart = TO_INTEGER(start);
45 if (!IS_UNDEFINED(end)) { 52 if (!IS_UNDEFINED(end)) {
46 end = TO_INTEGER(end); 53 end = TO_INTEGER(end);
47 } 54 }
48 var first; 55 var first;
49 var byte_length = %_ArrayBufferGetByteLength(this); 56 var byte_length = %_ArrayBufferGetByteLength(this);
50 if (relativeStart < 0) { 57 if (relativeStart < 0) {
51 first = MAX_SIMPLE(byte_length + relativeStart, 0); 58 first = MathMax(byte_length + relativeStart, 0);
52 } else { 59 } else {
53 first = MIN_SIMPLE(relativeStart, byte_length); 60 first = MathMin(relativeStart, byte_length);
54 } 61 }
55 var relativeEnd = IS_UNDEFINED(end) ? byte_length : end; 62 var relativeEnd = IS_UNDEFINED(end) ? byte_length : end;
56 var fin; 63 var fin;
57 if (relativeEnd < 0) { 64 if (relativeEnd < 0) {
58 fin = MAX_SIMPLE(byte_length + relativeEnd, 0); 65 fin = MathMax(byte_length + relativeEnd, 0);
59 } else { 66 } else {
60 fin = MIN_SIMPLE(relativeEnd, byte_length); 67 fin = MathMin(relativeEnd, byte_length);
61 } 68 }
62 69
63 if (fin < first) { 70 if (fin < first) {
64 fin = first; 71 fin = first;
65 } 72 }
66 var newLen = fin - first; 73 var newLen = fin - first;
67 // TODO(dslomov): implement inheritance 74 // TODO(dslomov): implement inheritance
68 var result = new GlobalArrayBuffer(newLen); 75 var result = new GlobalArrayBuffer(newLen);
69 76
70 %ArrayBufferSliceImpl(this, result, first); 77 %ArrayBufferSliceImpl(this, result, first);
(...skipping 21 matching lines...) Expand all
92 99
93 utils.InstallFunctions(GlobalArrayBuffer, DONT_ENUM, [ 100 utils.InstallFunctions(GlobalArrayBuffer, DONT_ENUM, [
94 "isView", ArrayBufferIsViewJS 101 "isView", ArrayBufferIsViewJS
95 ]); 102 ]);
96 103
97 utils.InstallFunctions(GlobalArrayBuffer.prototype, DONT_ENUM, [ 104 utils.InstallFunctions(GlobalArrayBuffer.prototype, DONT_ENUM, [
98 "slice", ArrayBufferSlice 105 "slice", ArrayBufferSlice
99 ]); 106 ]);
100 107
101 }) 108 })
OLDNEW
« no previous file with comments | « src/array.js ('k') | src/harmony-array.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698