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

Side by Side Diff: src/arraybuffer.js

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

Powered by Google App Engine
This is Rietveld 408576698