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

Side by Side Diff: src/js/arraybuffer.js

Issue 1410473002: Reland: Use simple/fast inline function version of MinMax in JS (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: use existing export in runtime 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
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;
18 var ToPositiveInteger; 16 var ToPositiveInteger;
19 var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol"); 17 var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
18 var MaxSimple;
Jakob Kummerow 2015/10/15 14:18:48 nit: please preserve alpha-sorting
skomski 2015/10/15 15:17:58 Done.
19 var MinSimple;
20 20
21 utils.Import(function(from) { 21 utils.Import(function(from) {
22 MathMax = from.MathMax; 22 MaxSimple = from.MaxSimple;
23 MathMin = from.MathMin; 23 MinSimple = from.MinSimple;
24 });
25
26 utils.Import(function(from) {
24 ToPositiveInteger = from.ToPositiveInteger; 27 ToPositiveInteger = from.ToPositiveInteger;
25 }); 28 });
26 29
27 // ------------------------------------------------------------------- 30 // -------------------------------------------------------------------
28 31
29 function ArrayBufferConstructor(length) { // length = 1 32 function ArrayBufferConstructor(length) { // length = 1
30 if (%_IsConstructCall()) { 33 if (%_IsConstructCall()) {
31 var byteLength = ToPositiveInteger(length, kInvalidArrayBufferLength); 34 var byteLength = ToPositiveInteger(length, kInvalidArrayBufferLength);
32 %ArrayBufferInitialize(this, byteLength, kNotShared); 35 %ArrayBufferInitialize(this, byteLength, kNotShared);
33 } else { 36 } else {
(...skipping 16 matching lines...) Expand all
50 'ArrayBuffer.prototype.slice', this); 53 'ArrayBuffer.prototype.slice', this);
51 } 54 }
52 55
53 var relativeStart = TO_INTEGER(start); 56 var relativeStart = TO_INTEGER(start);
54 if (!IS_UNDEFINED(end)) { 57 if (!IS_UNDEFINED(end)) {
55 end = TO_INTEGER(end); 58 end = TO_INTEGER(end);
56 } 59 }
57 var first; 60 var first;
58 var byte_length = %_ArrayBufferGetByteLength(this); 61 var byte_length = %_ArrayBufferGetByteLength(this);
59 if (relativeStart < 0) { 62 if (relativeStart < 0) {
60 first = MathMax(byte_length + relativeStart, 0); 63 first = MaxSimple(byte_length + relativeStart, 0);
61 } else { 64 } else {
62 first = MathMin(relativeStart, byte_length); 65 first = MinSimple(relativeStart, byte_length);
63 } 66 }
64 var relativeEnd = IS_UNDEFINED(end) ? byte_length : end; 67 var relativeEnd = IS_UNDEFINED(end) ? byte_length : end;
65 var fin; 68 var fin;
66 if (relativeEnd < 0) { 69 if (relativeEnd < 0) {
67 fin = MathMax(byte_length + relativeEnd, 0); 70 fin = MaxSimple(byte_length + relativeEnd, 0);
68 } else { 71 } else {
69 fin = MathMin(relativeEnd, byte_length); 72 fin = MinSimple(relativeEnd, byte_length);
70 } 73 }
71 74
72 if (fin < first) { 75 if (fin < first) {
73 fin = first; 76 fin = first;
74 } 77 }
75 var newLen = fin - first; 78 var newLen = fin - first;
76 // TODO(dslomov): implement inheritance 79 // TODO(dslomov): implement inheritance
77 var result = new GlobalArrayBuffer(newLen); 80 var result = new GlobalArrayBuffer(newLen);
78 81
79 %ArrayBufferSliceImpl(this, result, first); 82 %ArrayBufferSliceImpl(this, result, first);
(...skipping 21 matching lines...) Expand all
101 104
102 utils.InstallFunctions(GlobalArrayBuffer, DONT_ENUM, [ 105 utils.InstallFunctions(GlobalArrayBuffer, DONT_ENUM, [
103 "isView", ArrayBufferIsViewJS 106 "isView", ArrayBufferIsViewJS
104 ]); 107 ]);
105 108
106 utils.InstallFunctions(GlobalArrayBuffer.prototype, DONT_ENUM, [ 109 utils.InstallFunctions(GlobalArrayBuffer.prototype, DONT_ENUM, [
107 "slice", ArrayBufferSlice 110 "slice", ArrayBufferSlice
108 ]); 111 ]);
109 112
110 }) 113 })
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698