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

Side by Side Diff: src/apinatives.js

Issue 18096: Experimental: merge from bleeding_edge. Merge up to and including... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/toiger/
Patch Set: Created 11 years, 11 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 | « src/api.cc ('k') | src/assembler.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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 var result = Constructor ? new (Instantiate(Constructor))() : {}; 52 var result = Constructor ? new (Instantiate(Constructor))() : {};
53 ConfigureTemplateInstance(result, data); 53 ConfigureTemplateInstance(result, data);
54 return result; 54 return result;
55 default: 55 default:
56 throw 'Unknown API tag <' + tag + '>'; 56 throw 'Unknown API tag <' + tag + '>';
57 } 57 }
58 } 58 }
59 59
60 60
61 function InstantiateFunction(data, name) { 61 function InstantiateFunction(data, name) {
62 // We need a reference to kApiFunctionCache in the stack frame
63 // if we need to bail out from a stack overflow.
64 var cache = kApiFunctionCache;
62 var serialNumber = %GetTemplateField(data, kApiSerialNumberOffset); 65 var serialNumber = %GetTemplateField(data, kApiSerialNumberOffset);
63 if (!(serialNumber in kApiFunctionCache)) { 66 var isFunctionCached =
64 kApiFunctionCache[serialNumber] = null; 67 (serialNumber in cache) && (cache[serialNumber] != kUninitialized);
65 var fun = %CreateApiFunction(data); 68 if (!isFunctionCached) {
66 if (name) %FunctionSetName(fun, name); 69 try {
67 kApiFunctionCache[serialNumber] = fun; 70 cache[serialNumber] = null;
68 var prototype = %GetTemplateField(data, kApiPrototypeTemplateOffset); 71 var fun = %CreateApiFunction(data);
69 fun.prototype = prototype ? Instantiate(prototype) : {}; 72 if (name) %FunctionSetName(fun, name);
70 %SetProperty(fun.prototype, "constructor", fun, DONT_ENUM); 73 cache[serialNumber] = fun;
71 var parent = %GetTemplateField(data, kApiParentTemplateOffset); 74 var prototype = %GetTemplateField(data, kApiPrototypeTemplateOffset);
72 if (parent) { 75 fun.prototype = prototype ? Instantiate(prototype) : {};
73 var parent_fun = Instantiate(parent); 76 %SetProperty(fun.prototype, "constructor", fun, DONT_ENUM);
74 fun.prototype.__proto__ = parent_fun.prototype; 77 var parent = %GetTemplateField(data, kApiParentTemplateOffset);
78 if (parent) {
79 var parent_fun = Instantiate(parent);
80 fun.prototype.__proto__ = parent_fun.prototype;
81 }
82 ConfigureTemplateInstance(fun, data);
83 } catch (e) {
84 cache[serialNumber] = kUninitialized;
85 throw e;
75 } 86 }
76 ConfigureTemplateInstance(fun, data);
77 } 87 }
78 return kApiFunctionCache[serialNumber]; 88 return cache[serialNumber];
79 } 89 }
80 90
81 91
82 function ConfigureTemplateInstance(obj, data) { 92 function ConfigureTemplateInstance(obj, data) {
83 var properties = %GetTemplateField(data, kApiPropertyListOffset); 93 var properties = %GetTemplateField(data, kApiPropertyListOffset);
84 if (properties) { 94 if (properties) {
85 // Disable access checks while instantiating the object. 95 // Disable access checks while instantiating the object.
86 var requires_access_checks = %DisableAccessChecks(obj); 96 var requires_access_checks = %DisableAccessChecks(obj);
87 try { 97 try {
88 for (var i = 0; i < properties[0]; i += 3) { 98 for (var i = 0; i < properties[0]; i += 3) {
89 var name = properties[i + 1]; 99 var name = properties[i + 1];
90 var prop_data = properties[i + 2]; 100 var prop_data = properties[i + 2];
91 var attributes = properties[i + 3]; 101 var attributes = properties[i + 3];
92 var value = Instantiate(prop_data, name); 102 var value = Instantiate(prop_data, name);
93 %SetProperty(obj, name, value, attributes); 103 %SetProperty(obj, name, value, attributes);
94 } 104 }
95 } finally { 105 } finally {
96 if (requires_access_checks) %EnableAccessChecks(obj); 106 if (requires_access_checks) %EnableAccessChecks(obj);
97 } 107 }
98 } 108 }
99 } 109 }
OLDNEW
« no previous file with comments | « src/api.cc ('k') | src/assembler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698