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

Side by Side Diff: src/apinatives.js

Issue 274463003: Directly create API functions with readonly prototypes rather than converting. Remove FunctionSetRe… (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Remove test Created 6 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 | Annotate | Revision Log
« no previous file with comments | « include/v8.h ('k') | src/bootstrapper.cc » ('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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 // This file contains infrastructure used by the API. See 5 // This file contains infrastructure used by the API. See
6 // v8natives.js for an explanation of these files are processed and 6 // v8natives.js for an explanation of these files are processed and
7 // loaded. 7 // loaded.
8 8
9 9
10 function CreateDate(time) { 10 function CreateDate(time) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 function InstantiateFunction(data, name) { 42 function InstantiateFunction(data, name) {
43 // We need a reference to kApiFunctionCache in the stack frame 43 // We need a reference to kApiFunctionCache in the stack frame
44 // if we need to bail out from a stack overflow. 44 // if we need to bail out from a stack overflow.
45 var cache = kApiFunctionCache; 45 var cache = kApiFunctionCache;
46 var serialNumber = %GetTemplateField(data, kApiSerialNumberOffset); 46 var serialNumber = %GetTemplateField(data, kApiSerialNumberOffset);
47 var isFunctionCached = 47 var isFunctionCached =
48 (serialNumber in cache) && (cache[serialNumber] != kUninitialized); 48 (serialNumber in cache) && (cache[serialNumber] != kUninitialized);
49 if (!isFunctionCached) { 49 if (!isFunctionCached) {
50 try { 50 try {
51 var flags = %GetTemplateField(data, kApiFlagOffset); 51 var flags = %GetTemplateField(data, kApiFlagOffset);
52 var has_proto = !(flags & (1 << kRemovePrototypeBit));
53 var prototype; 52 var prototype;
54 if (has_proto) { 53 if (!(flags & (1 << kRemovePrototypeBit))) {
55 var template = %GetTemplateField(data, kApiPrototypeTemplateOffset); 54 var template = %GetTemplateField(data, kApiPrototypeTemplateOffset);
56 prototype = typeof template === 'undefined' 55 prototype = typeof template === 'undefined'
57 ? {} : Instantiate(template); 56 ? {} : Instantiate(template);
58 57
59 var parent = %GetTemplateField(data, kApiParentTemplateOffset); 58 var parent = %GetTemplateField(data, kApiParentTemplateOffset);
60 // Note: Do not directly use a function template as a condition, our 59 // Note: Do not directly use a function template as a condition, our
61 // internal ToBoolean doesn't handle that! 60 // internal ToBoolean doesn't handle that!
62 if (typeof parent !== 'undefined') { 61 if (typeof parent !== 'undefined') {
63 var parent_fun = Instantiate(parent); 62 var parent_fun = Instantiate(parent);
64 %SetPrototype(prototype, parent_fun.prototype); 63 %SetPrototype(prototype, parent_fun.prototype);
65 } 64 }
66 } 65 }
67 var fun = %CreateApiFunction(data, prototype); 66 var fun = %CreateApiFunction(data, prototype);
68 if (name) %FunctionSetName(fun, name); 67 if (name) %FunctionSetName(fun, name);
69 var doNotCache = flags & (1 << kDoNotCacheBit); 68 var doNotCache = flags & (1 << kDoNotCacheBit);
70 if (!doNotCache) cache[serialNumber] = fun; 69 if (!doNotCache) cache[serialNumber] = fun;
71 if (has_proto && flags & (1 << kReadOnlyPrototypeBit)) {
72 %FunctionSetReadOnlyPrototype(fun);
73 }
74 ConfigureTemplateInstance(fun, data); 70 ConfigureTemplateInstance(fun, data);
75 if (doNotCache) return fun; 71 if (doNotCache) return fun;
76 } catch (e) { 72 } catch (e) {
77 cache[serialNumber] = kUninitialized; 73 cache[serialNumber] = kUninitialized;
78 throw e; 74 throw e;
79 } 75 }
80 } 76 }
81 return cache[serialNumber]; 77 return cache[serialNumber];
82 } 78 }
83 79
(...skipping 22 matching lines...) Expand all
106 obj, name, getter, setter, attribute, access_control); 102 obj, name, getter, setter, attribute, access_control);
107 } else { 103 } else {
108 throw "Bad properties array"; 104 throw "Bad properties array";
109 } 105 }
110 i += length + 1; 106 i += length + 1;
111 } 107 }
112 } finally { 108 } finally {
113 if (requires_access_checks) %EnableAccessChecks(obj); 109 if (requires_access_checks) %EnableAccessChecks(obj);
114 } 110 }
115 } 111 }
OLDNEW
« no previous file with comments | « include/v8.h ('k') | src/bootstrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698