Chromium Code Reviews| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 | 62 // We need a reference to kApiFunctionCache in the stack frame |
| 63 // if we need to bail out from a stack overflow. | 63 // if we need to bail out from a stack overflow. |
| 64 var cache = kApiFunctionCache; | 64 var cache = kApiFunctionCache; |
| 65 var serialNumber = %GetTemplateField(data, kApiSerialNumberOffset); | 65 var serialNumber = %GetTemplateField(data, kApiSerialNumberOffset); |
| 66 var isFunctionCached = | 66 var isFunctionCached = |
| 67 (serialNumber in cache) && | 67 (serialNumber in cache) && |
| 68 (cache[serialNumber] != -1); | 68 (cache[serialNumber] != kUninitialized); |
|
Mads Ager (chromium)
2009/01/13 07:35:37
This would fit on the line above now that the loca
olehougaard
2009/01/13 07:37:23
Fixed
| |
| 69 if (!isFunctionCached) { | 69 if (!isFunctionCached) { |
| 70 try { | 70 try { |
| 71 cache[serialNumber] = null; | 71 cache[serialNumber] = null; |
| 72 var fun = %CreateApiFunction(data); | 72 var fun = %CreateApiFunction(data); |
| 73 if (name) %FunctionSetName(fun, name); | 73 if (name) %FunctionSetName(fun, name); |
| 74 cache[serialNumber] = fun; | 74 cache[serialNumber] = fun; |
| 75 var prototype = %GetTemplateField(data, kApiPrototypeTemplateOffset); | 75 var prototype = %GetTemplateField(data, kApiPrototypeTemplateOffset); |
| 76 fun.prototype = prototype ? Instantiate(prototype) : {}; | 76 fun.prototype = prototype ? Instantiate(prototype) : {}; |
| 77 %SetProperty(fun.prototype, "constructor", fun, DONT_ENUM); | 77 %SetProperty(fun.prototype, "constructor", fun, DONT_ENUM); |
| 78 var parent = %GetTemplateField(data, kApiParentTemplateOffset); | 78 var parent = %GetTemplateField(data, kApiParentTemplateOffset); |
| 79 if (parent) { | 79 if (parent) { |
| 80 var parent_fun = Instantiate(parent); | 80 var parent_fun = Instantiate(parent); |
| 81 fun.prototype.__proto__ = parent_fun.prototype; | 81 fun.prototype.__proto__ = parent_fun.prototype; |
| 82 } | 82 } |
| 83 ConfigureTemplateInstance(fun, data); | 83 ConfigureTemplateInstance(fun, data); |
| 84 } catch (e) { | 84 } catch (e) { |
| 85 cache[serialNumber] = -1; | 85 cache[serialNumber] = kUninitialized; |
| 86 throw e; | 86 throw e; |
| 87 } | 87 } |
| 88 } | 88 } |
| 89 return cache[serialNumber]; | 89 return cache[serialNumber]; |
| 90 } | 90 } |
| 91 | 91 |
| 92 | 92 |
| 93 function ConfigureTemplateInstance(obj, data) { | 93 function ConfigureTemplateInstance(obj, data) { |
| 94 var properties = %GetTemplateField(data, kApiPropertyListOffset); | 94 var properties = %GetTemplateField(data, kApiPropertyListOffset); |
| 95 if (properties) { | 95 if (properties) { |
| 96 // Disable access checks while instantiating the object. | 96 // Disable access checks while instantiating the object. |
| 97 var requires_access_checks = %DisableAccessChecks(obj); | 97 var requires_access_checks = %DisableAccessChecks(obj); |
| 98 try { | 98 try { |
| 99 for (var i = 0; i < properties[0]; i += 3) { | 99 for (var i = 0; i < properties[0]; i += 3) { |
| 100 var name = properties[i + 1]; | 100 var name = properties[i + 1]; |
| 101 var prop_data = properties[i + 2]; | 101 var prop_data = properties[i + 2]; |
| 102 var attributes = properties[i + 3]; | 102 var attributes = properties[i + 3]; |
| 103 var value = Instantiate(prop_data, name); | 103 var value = Instantiate(prop_data, name); |
| 104 %SetProperty(obj, name, value, attributes); | 104 %SetProperty(obj, name, value, attributes); |
| 105 } | 105 } |
| 106 } finally { | 106 } finally { |
| 107 if (requires_access_checks) %EnableAccessChecks(obj); | 107 if (requires_access_checks) %EnableAccessChecks(obj); |
| 108 } | 108 } |
| 109 } | 109 } |
| 110 } | 110 } |
| OLD | NEW |