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

Side by Side Diff: src/collection.js

Issue 1140743004: Generalize builtins inlining flag to allow forced inlining of any function (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix comment Created 5 years, 7 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 | « no previous file | src/compiler.h » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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, shared, exports) { 5 (function(global, shared, exports) {
6 6
7 "use strict"; 7 "use strict";
8 8
9 %CheckIsBootstrapping(); 9 %CheckIsBootstrapping();
10 10
11 var GlobalMap = global.Map; 11 var GlobalMap = global.Map;
12 var GlobalObject = global.Object; 12 var GlobalObject = global.Object;
13 var GlobalSet = global.Set; 13 var GlobalSet = global.Set;
14 14
15 // ------------------------------------------------------------------- 15 // -------------------------------------------------------------------
16 16
17 function HashToEntry(table, hash, numBuckets) { 17 function HashToEntry(table, hash, numBuckets) {
18 var bucket = ORDERED_HASH_TABLE_HASH_TO_BUCKET(hash, numBuckets); 18 var bucket = ORDERED_HASH_TABLE_HASH_TO_BUCKET(hash, numBuckets);
19 return ORDERED_HASH_TABLE_BUCKET_AT(table, bucket); 19 return ORDERED_HASH_TABLE_BUCKET_AT(table, bucket);
20 } 20 }
21 %SetInlineBuiltinFlag(HashToEntry); 21 %SetForceInlineFlag(HashToEntry);
22 22
23 23
24 function SetFindEntry(table, numBuckets, key, hash) { 24 function SetFindEntry(table, numBuckets, key, hash) {
25 var keyIsNaN = $numberIsNaN(key); 25 var keyIsNaN = $numberIsNaN(key);
26 for (var entry = HashToEntry(table, hash, numBuckets); 26 for (var entry = HashToEntry(table, hash, numBuckets);
27 entry !== NOT_FOUND; 27 entry !== NOT_FOUND;
28 entry = ORDERED_HASH_SET_CHAIN_AT(table, entry, numBuckets)) { 28 entry = ORDERED_HASH_SET_CHAIN_AT(table, entry, numBuckets)) {
29 var candidate = ORDERED_HASH_SET_KEY_AT(table, entry, numBuckets); 29 var candidate = ORDERED_HASH_SET_KEY_AT(table, entry, numBuckets);
30 if (key === candidate) { 30 if (key === candidate) {
31 return entry; 31 return entry;
32 } 32 }
33 if (keyIsNaN && $numberIsNaN(candidate)) { 33 if (keyIsNaN && $numberIsNaN(candidate)) {
34 return entry; 34 return entry;
35 } 35 }
36 } 36 }
37 return NOT_FOUND; 37 return NOT_FOUND;
38 } 38 }
39 %SetInlineBuiltinFlag(SetFindEntry); 39 %SetForceInlineFlag(SetFindEntry);
40 40
41 41
42 function MapFindEntry(table, numBuckets, key, hash) { 42 function MapFindEntry(table, numBuckets, key, hash) {
43 var keyIsNaN = $numberIsNaN(key); 43 var keyIsNaN = $numberIsNaN(key);
44 for (var entry = HashToEntry(table, hash, numBuckets); 44 for (var entry = HashToEntry(table, hash, numBuckets);
45 entry !== NOT_FOUND; 45 entry !== NOT_FOUND;
46 entry = ORDERED_HASH_MAP_CHAIN_AT(table, entry, numBuckets)) { 46 entry = ORDERED_HASH_MAP_CHAIN_AT(table, entry, numBuckets)) {
47 var candidate = ORDERED_HASH_MAP_KEY_AT(table, entry, numBuckets); 47 var candidate = ORDERED_HASH_MAP_KEY_AT(table, entry, numBuckets);
48 if (key === candidate) { 48 if (key === candidate) {
49 return entry; 49 return entry;
50 } 50 }
51 if (keyIsNaN && $numberIsNaN(candidate)) { 51 if (keyIsNaN && $numberIsNaN(candidate)) {
52 return entry; 52 return entry;
53 } 53 }
54 } 54 }
55 return NOT_FOUND; 55 return NOT_FOUND;
56 } 56 }
57 %SetInlineBuiltinFlag(MapFindEntry); 57 %SetForceInlineFlag(MapFindEntry);
58 58
59 59
60 function ComputeIntegerHash(key, seed) { 60 function ComputeIntegerHash(key, seed) {
61 var hash = key; 61 var hash = key;
62 hash = hash ^ seed; 62 hash = hash ^ seed;
63 hash = ~hash + (hash << 15); // hash = (hash << 15) - hash - 1; 63 hash = ~hash + (hash << 15); // hash = (hash << 15) - hash - 1;
64 hash = hash ^ (hash >>> 12); 64 hash = hash ^ (hash >>> 12);
65 hash = hash + (hash << 2); 65 hash = hash + (hash << 2);
66 hash = hash ^ (hash >>> 4); 66 hash = hash ^ (hash >>> 4);
67 hash = (hash * 2057) | 0; // hash = (hash + (hash << 3)) + (hash << 11); 67 hash = (hash * 2057) | 0; // hash = (hash + (hash << 3)) + (hash << 11);
68 hash = hash ^ (hash >>> 16); 68 hash = hash ^ (hash >>> 16);
69 return hash; 69 return hash;
70 } 70 }
71 %SetInlineBuiltinFlag(ComputeIntegerHash); 71 %SetForceInlineFlag(ComputeIntegerHash);
72 72
73 73
74 function GetHash(key) { 74 function GetHash(key) {
75 if (%_IsSmi(key)) { 75 if (%_IsSmi(key)) {
76 return ComputeIntegerHash(key, 0); 76 return ComputeIntegerHash(key, 0);
77 } 77 }
78 if (IS_STRING(key)) { 78 if (IS_STRING(key)) {
79 var field = %_StringGetRawHashField(key); 79 var field = %_StringGetRawHashField(key);
80 if ((field & 1 /* Name::kHashNotComputedMask */) === 0) { 80 if ((field & 1 /* Name::kHashNotComputedMask */) === 0) {
81 return field >>> 2 /* Name::kHashShift */; 81 return field >>> 2 /* Name::kHashShift */;
82 } 82 }
83 } 83 }
84 return %GenericHash(key); 84 return %GenericHash(key);
85 } 85 }
86 %SetInlineBuiltinFlag(GetHash); 86 %SetForceInlineFlag(GetHash);
87 87
88 88
89 // ------------------------------------------------------------------- 89 // -------------------------------------------------------------------
90 // Harmony Set 90 // Harmony Set
91 91
92 function SetConstructor(iterable) { 92 function SetConstructor(iterable) {
93 if (!%_IsConstructCall()) { 93 if (!%_IsConstructCall()) {
94 throw MakeTypeError(kConstructorNotFunction, "Set"); 94 throw MakeTypeError(kConstructorNotFunction, "Set");
95 } 95 }
96 96
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 $installFunctions(GlobalMap.prototype, DONT_ENUM, [ 431 $installFunctions(GlobalMap.prototype, DONT_ENUM, [
432 "get", MapGet, 432 "get", MapGet,
433 "set", MapSet, 433 "set", MapSet,
434 "has", MapHas, 434 "has", MapHas,
435 "delete", MapDelete, 435 "delete", MapDelete,
436 "clear", MapClearJS, 436 "clear", MapClearJS,
437 "forEach", MapForEach 437 "forEach", MapForEach
438 ]); 438 ]);
439 439
440 }) 440 })
OLDNEW
« no previous file with comments | « no previous file | src/compiler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698