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

Side by Side Diff: src/harmony-templates.js

Issue 947683002: Reimplement Maps and Sets in JS (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rename all the things, add more macros, and remove unnecessary %_CallFunctions Created 5 years, 9 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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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 "use strict"; 5 "use strict";
6 6
7 var callSiteCache = new $Map; 7 var callSiteCache = new $Map;
8 8
9 function SameCallSiteElements(rawStrings, other) { 9 function SameCallSiteElements(rawStrings, other) {
10 var length = rawStrings.length; 10 var length = rawStrings.length;
11 var other = other.raw; 11 var other = other.raw;
12 12
13 if (length !== other.length) return false; 13 if (length !== other.length) return false;
14 14
15 for (var i = 0; i < length; ++i) { 15 for (var i = 0; i < length; ++i) {
16 if (rawStrings[i] !== other[i]) return false; 16 if (rawStrings[i] !== other[i]) return false;
17 } 17 }
18 18
19 return true; 19 return true;
20 } 20 }
21 21
22 22
23 function GetCachedCallSite(siteObj, hash) { 23 function GetCachedCallSite(siteObj, hash) {
24 var obj = %MapGet(callSiteCache, hash); 24 var obj = %_CallFunction(callSiteCache, hash, $MapGet);
caitp (gmail) 2015/03/25 12:56:27 Couldn't we just call MapGet() (and others) direct
adamk 2015/03/25 15:43:06 MapGet is now inside a closure, so it's not visibl
caitp (gmail) 2015/03/25 15:46:24 I mean, you have a reference to $MapGet, otherwise
adamk 2015/03/25 16:13:36 Not sure what you're saying. I could have called "
adamk 2015/03/25 16:14:24 Or are you asking about the use of %_CallFunction(
caitp (gmail) 2015/03/25 16:31:50 OH --- derp, you're right. Course, this map here i
25 25
26 if (IS_UNDEFINED(obj)) return; 26 if (IS_UNDEFINED(obj)) return;
27 27
28 var length = obj.length; 28 var length = obj.length;
29 for (var i = 0; i < length; ++i) { 29 for (var i = 0; i < length; ++i) {
30 if (SameCallSiteElements(siteObj, obj[i])) return obj[i]; 30 if (SameCallSiteElements(siteObj, obj[i])) return obj[i];
31 } 31 }
32 } 32 }
33 33
34 34
35 function SetCachedCallSite(siteObj, hash) { 35 function SetCachedCallSite(siteObj, hash) {
36 var obj = %MapGet(callSiteCache, hash); 36 var obj = %_CallFunction(callSiteCache, hash, $MapGet);
37 var array; 37 var array;
38 38
39 if (IS_UNDEFINED(obj)) { 39 if (IS_UNDEFINED(obj)) {
40 array = new InternalArray(1); 40 array = new InternalArray(1);
41 array[0] = siteObj; 41 array[0] = siteObj;
42 %MapSet(callSiteCache, hash, array); 42 %_CallFunction(callSiteCache, hash, array, $MapSet);
43 } else { 43 } else {
44 obj.push(siteObj); 44 obj.push(siteObj);
45 } 45 }
46 46
47 return siteObj; 47 return siteObj;
48 } 48 }
49 49
50 50
51 function GetTemplateCallSite(siteObj, rawStrings, hash) { 51 function GetTemplateCallSite(siteObj, rawStrings, hash) {
52 var cached = GetCachedCallSite(rawStrings, hash); 52 var cached = GetCachedCallSite(rawStrings, hash);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 function ExtendStringForTemplates() { 85 function ExtendStringForTemplates() {
86 %CheckIsBootstrapping(); 86 %CheckIsBootstrapping();
87 87
88 // Set up the non-enumerable functions on the String object. 88 // Set up the non-enumerable functions on the String object.
89 InstallFunctions($String, DONT_ENUM, $Array( 89 InstallFunctions($String, DONT_ENUM, $Array(
90 "raw", StringRaw 90 "raw", StringRaw
91 )); 91 ));
92 } 92 }
93 93
94 ExtendStringForTemplates(); 94 ExtendStringForTemplates();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698