OLD | NEW |
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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 function Instantiate(data, name) { | 44 function Instantiate(data, name) { |
45 if (!%IsTemplate(data)) return data; | 45 if (!%IsTemplate(data)) return data; |
46 var tag = %GetTemplateField(data, kApiTagOffset); | 46 var tag = %GetTemplateField(data, kApiTagOffset); |
47 switch (tag) { | 47 switch (tag) { |
48 case kFunctionTag: | 48 case kFunctionTag: |
49 return InstantiateFunction(data, name); | 49 return InstantiateFunction(data, name); |
50 case kNewObjectTag: | 50 case kNewObjectTag: |
51 var Constructor = %GetTemplateField(data, kApiConstructorOffset); | 51 var Constructor = %GetTemplateField(data, kApiConstructorOffset); |
52 var result = Constructor ? new (Instantiate(Constructor))() : {}; | 52 var result = Constructor ? new (Instantiate(Constructor))() : {}; |
53 ConfigureTemplateInstance(result, data); | 53 ConfigureTemplateInstance(result, data); |
| 54 result = %ToFastProperties(result); |
54 return result; | 55 return result; |
55 default: | 56 default: |
56 throw 'Unknown API tag <' + tag + '>'; | 57 throw 'Unknown API tag <' + tag + '>'; |
57 } | 58 } |
58 } | 59 } |
59 | 60 |
60 | 61 |
61 function InstantiateFunction(data, name) { | 62 function InstantiateFunction(data, name) { |
62 // We need a reference to kApiFunctionCache in the stack frame | 63 // We need a reference to kApiFunctionCache in the stack frame |
63 // if we need to bail out from a stack overflow. | 64 // if we need to bail out from a stack overflow. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 var prop_data = properties[i + 2]; | 101 var prop_data = properties[i + 2]; |
101 var attributes = properties[i + 3]; | 102 var attributes = properties[i + 3]; |
102 var value = Instantiate(prop_data, name); | 103 var value = Instantiate(prop_data, name); |
103 %SetProperty(obj, name, value, attributes); | 104 %SetProperty(obj, name, value, attributes); |
104 } | 105 } |
105 } finally { | 106 } finally { |
106 if (requires_access_checks) %EnableAccessChecks(obj); | 107 if (requires_access_checks) %EnableAccessChecks(obj); |
107 } | 108 } |
108 } | 109 } |
109 } | 110 } |
OLD | NEW |