OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 1880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1891 return static_cast<uint32_t>(num->Number()); | 1891 return static_cast<uint32_t>(num->Number()); |
1892 } | 1892 } |
1893 } | 1893 } |
1894 } | 1894 } |
1895 | 1895 |
1896 | 1896 |
1897 bool v8::Object::Set(v8::Handle<Value> key, v8::Handle<Value> value, | 1897 bool v8::Object::Set(v8::Handle<Value> key, v8::Handle<Value> value, |
1898 v8::PropertyAttribute attribs) { | 1898 v8::PropertyAttribute attribs) { |
1899 ON_BAILOUT("v8::Object::Set()", return false); | 1899 ON_BAILOUT("v8::Object::Set()", return false); |
1900 ENTER_V8; | 1900 ENTER_V8; |
| 1901 HandleScope scope; |
1901 i::Handle<i::Object> self = Utils::OpenHandle(this); | 1902 i::Handle<i::Object> self = Utils::OpenHandle(this); |
1902 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); | 1903 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); |
1903 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); | 1904 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); |
1904 EXCEPTION_PREAMBLE(); | 1905 EXCEPTION_PREAMBLE(); |
1905 i::Handle<i::Object> obj = i::SetProperty( | 1906 i::Handle<i::Object> obj = i::SetProperty( |
1906 self, | 1907 self, |
1907 key_obj, | 1908 key_obj, |
1908 value_obj, | 1909 value_obj, |
1909 static_cast<PropertyAttributes>(attribs)); | 1910 static_cast<PropertyAttributes>(attribs)); |
1910 has_pending_exception = obj.is_null(); | 1911 has_pending_exception = obj.is_null(); |
1911 EXCEPTION_BAILOUT_CHECK(false); | 1912 EXCEPTION_BAILOUT_CHECK(false); |
1912 return true; | 1913 return true; |
1913 } | 1914 } |
1914 | 1915 |
1915 | 1916 |
1916 bool v8::Object::ForceSet(v8::Handle<Value> key, | 1917 bool v8::Object::ForceSet(v8::Handle<Value> key, |
1917 v8::Handle<Value> value, | 1918 v8::Handle<Value> value, |
1918 v8::PropertyAttribute attribs) { | 1919 v8::PropertyAttribute attribs) { |
1919 ON_BAILOUT("v8::Object::ForceSet()", return false); | 1920 ON_BAILOUT("v8::Object::ForceSet()", return false); |
1920 ENTER_V8; | 1921 ENTER_V8; |
| 1922 HandleScope scope; |
1921 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 1923 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
1922 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); | 1924 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); |
1923 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); | 1925 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); |
1924 EXCEPTION_PREAMBLE(); | 1926 EXCEPTION_PREAMBLE(); |
1925 i::Handle<i::Object> obj = i::ForceSetProperty( | 1927 i::Handle<i::Object> obj = i::ForceSetProperty( |
1926 self, | 1928 self, |
1927 key_obj, | 1929 key_obj, |
1928 value_obj, | 1930 value_obj, |
1929 static_cast<PropertyAttributes>(attribs)); | 1931 static_cast<PropertyAttributes>(attribs)); |
1930 has_pending_exception = obj.is_null(); | 1932 has_pending_exception = obj.is_null(); |
1931 EXCEPTION_BAILOUT_CHECK(false); | 1933 EXCEPTION_BAILOUT_CHECK(false); |
1932 return true; | 1934 return true; |
1933 } | 1935 } |
1934 | 1936 |
1935 | 1937 |
1936 bool v8::Object::ForceDelete(v8::Handle<Value> key) { | 1938 bool v8::Object::ForceDelete(v8::Handle<Value> key) { |
1937 ON_BAILOUT("v8::Object::ForceDelete()", return false); | 1939 ON_BAILOUT("v8::Object::ForceDelete()", return false); |
1938 ENTER_V8; | 1940 ENTER_V8; |
| 1941 HandleScope scope; |
1939 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 1942 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
1940 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); | 1943 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); |
1941 EXCEPTION_PREAMBLE(); | 1944 EXCEPTION_PREAMBLE(); |
1942 i::Handle<i::Object> obj = i::ForceDeleteProperty(self, key_obj); | 1945 i::Handle<i::Object> obj = i::ForceDeleteProperty(self, key_obj); |
1943 has_pending_exception = obj.is_null(); | 1946 has_pending_exception = obj.is_null(); |
1944 EXCEPTION_BAILOUT_CHECK(false); | 1947 EXCEPTION_BAILOUT_CHECK(false); |
1945 return obj->IsTrue(); | 1948 return obj->IsTrue(); |
1946 } | 1949 } |
1947 | 1950 |
1948 | 1951 |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2114 return Utils::OpenHandle(this)->HasNamedInterceptor(); | 2117 return Utils::OpenHandle(this)->HasNamedInterceptor(); |
2115 } | 2118 } |
2116 | 2119 |
2117 | 2120 |
2118 bool v8::Object::HasIndexedLookupInterceptor() { | 2121 bool v8::Object::HasIndexedLookupInterceptor() { |
2119 ON_BAILOUT("v8::Object::HasIndexedLookupInterceptor()", return false); | 2122 ON_BAILOUT("v8::Object::HasIndexedLookupInterceptor()", return false); |
2120 return Utils::OpenHandle(this)->HasIndexedInterceptor(); | 2123 return Utils::OpenHandle(this)->HasIndexedInterceptor(); |
2121 } | 2124 } |
2122 | 2125 |
2123 | 2126 |
2124 Handle<Value> v8::Object::GetRealNamedPropertyInPrototypeChain( | 2127 Local<Value> v8::Object::GetRealNamedPropertyInPrototypeChain( |
2125 Handle<String> key) { | 2128 Handle<String> key) { |
2126 ON_BAILOUT("v8::Object::GetRealNamedPropertyInPrototypeChain()", | 2129 ON_BAILOUT("v8::Object::GetRealNamedPropertyInPrototypeChain()", |
2127 return Local<Value>()); | 2130 return Local<Value>()); |
2128 ENTER_V8; | 2131 ENTER_V8; |
2129 i::Handle<i::JSObject> self_obj = Utils::OpenHandle(this); | 2132 i::Handle<i::JSObject> self_obj = Utils::OpenHandle(this); |
2130 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); | 2133 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); |
2131 i::LookupResult lookup; | 2134 i::LookupResult lookup; |
2132 self_obj->LookupRealNamedPropertyInPrototypes(*key_obj, &lookup); | 2135 self_obj->LookupRealNamedPropertyInPrototypes(*key_obj, &lookup); |
2133 if (lookup.IsValid()) { | 2136 if (lookup.IsValid()) { |
2134 PropertyAttributes attributes; | 2137 PropertyAttributes attributes; |
2135 i::Handle<i::Object> result(self_obj->GetProperty(*self_obj, | 2138 i::Handle<i::Object> result(self_obj->GetProperty(*self_obj, |
2136 &lookup, | 2139 &lookup, |
2137 *key_obj, | 2140 *key_obj, |
2138 &attributes)); | 2141 &attributes)); |
2139 return Utils::ToLocal(result); | 2142 return Utils::ToLocal(result); |
2140 } | 2143 } |
2141 return Local<Value>(); // No real property was found in prototype chain. | 2144 return Local<Value>(); // No real property was found in prototype chain. |
2142 } | 2145 } |
2143 | 2146 |
2144 | 2147 |
| 2148 Local<Value> v8::Object::GetRealNamedProperty(Handle<String> key) { |
| 2149 ON_BAILOUT("v8::Object::GetRealNamedProperty()", return Local<Value>()); |
| 2150 ENTER_V8; |
| 2151 i::Handle<i::JSObject> self_obj = Utils::OpenHandle(this); |
| 2152 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); |
| 2153 i::LookupResult lookup; |
| 2154 self_obj->LookupRealNamedProperty(*key_obj, &lookup); |
| 2155 if (lookup.IsValid()) { |
| 2156 PropertyAttributes attributes; |
| 2157 i::Handle<i::Object> result(self_obj->GetProperty(*self_obj, |
| 2158 &lookup, |
| 2159 *key_obj, |
| 2160 &attributes)); |
| 2161 return Utils::ToLocal(result); |
| 2162 } |
| 2163 return Local<Value>(); // No real property was found in prototype chain. |
| 2164 } |
| 2165 |
| 2166 |
2145 // Turns on access checks by copying the map and setting the check flag. | 2167 // Turns on access checks by copying the map and setting the check flag. |
2146 // Because the object gets a new map, existing inline cache caching | 2168 // Because the object gets a new map, existing inline cache caching |
2147 // the old map of this object will fail. | 2169 // the old map of this object will fail. |
2148 void v8::Object::TurnOnAccessCheck() { | 2170 void v8::Object::TurnOnAccessCheck() { |
2149 ON_BAILOUT("v8::Object::TurnOnAccessCheck()", return); | 2171 ON_BAILOUT("v8::Object::TurnOnAccessCheck()", return); |
2150 ENTER_V8; | 2172 ENTER_V8; |
| 2173 HandleScope scope; |
2151 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); | 2174 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); |
2152 | 2175 |
2153 i::Handle<i::Map> new_map = | 2176 i::Handle<i::Map> new_map = |
2154 i::Factory::CopyMapDropTransitions(i::Handle<i::Map>(obj->map())); | 2177 i::Factory::CopyMapDropTransitions(i::Handle<i::Map>(obj->map())); |
2155 new_map->set_is_access_check_needed(true); | 2178 new_map->set_is_access_check_needed(true); |
2156 obj->set_map(*new_map); | 2179 obj->set_map(*new_map); |
2157 } | 2180 } |
2158 | 2181 |
2159 | 2182 |
2160 bool v8::Object::IsDirty() { | 2183 bool v8::Object::IsDirty() { |
2161 return Utils::OpenHandle(this)->IsDirty(); | 2184 return Utils::OpenHandle(this)->IsDirty(); |
2162 } | 2185 } |
2163 | 2186 |
2164 | 2187 |
2165 Local<v8::Object> v8::Object::Clone() { | 2188 Local<v8::Object> v8::Object::Clone() { |
2166 ON_BAILOUT("v8::Object::Clone()", return Local<Object>()); | 2189 ON_BAILOUT("v8::Object::Clone()", return Local<Object>()); |
2167 ENTER_V8; | 2190 ENTER_V8; |
2168 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 2191 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
2169 EXCEPTION_PREAMBLE(); | 2192 EXCEPTION_PREAMBLE(); |
2170 i::Handle<i::JSObject> result = i::Copy(self); | 2193 i::Handle<i::JSObject> result = i::Copy(self); |
2171 has_pending_exception = result.is_null(); | 2194 has_pending_exception = result.is_null(); |
2172 EXCEPTION_BAILOUT_CHECK(Local<Object>()); | 2195 EXCEPTION_BAILOUT_CHECK(Local<Object>()); |
2173 return Utils::ToLocal(result); | 2196 return Utils::ToLocal(result); |
2174 } | 2197 } |
2175 | 2198 |
2176 | 2199 |
2177 int v8::Object::GetIdentityHash() { | 2200 int v8::Object::GetIdentityHash() { |
2178 ON_BAILOUT("v8::Object::GetIdentityHash()", return 0); | 2201 ON_BAILOUT("v8::Object::GetIdentityHash()", return 0); |
2179 ENTER_V8; | 2202 ENTER_V8; |
| 2203 HandleScope scope; |
2180 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 2204 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
2181 i::Handle<i::Object> hidden_props(i::GetHiddenProperties(self, true)); | 2205 i::Handle<i::Object> hidden_props(i::GetHiddenProperties(self, true)); |
2182 i::Handle<i::Object> hash_symbol = i::Factory::identity_hash_symbol(); | 2206 i::Handle<i::Object> hash_symbol = i::Factory::identity_hash_symbol(); |
2183 i::Handle<i::Object> hash = i::GetProperty(hidden_props, hash_symbol); | 2207 i::Handle<i::Object> hash = i::GetProperty(hidden_props, hash_symbol); |
2184 int hash_value; | 2208 int hash_value; |
2185 if (hash->IsSmi()) { | 2209 if (hash->IsSmi()) { |
2186 hash_value = i::Smi::cast(*hash)->value(); | 2210 hash_value = i::Smi::cast(*hash)->value(); |
2187 } else { | 2211 } else { |
2188 int attempts = 0; | 2212 int attempts = 0; |
2189 do { | 2213 do { |
2190 // Generate a random 32-bit hash value but limit range to fit | 2214 // Generate a random 32-bit hash value but limit range to fit |
2191 // within a smi. | 2215 // within a smi. |
2192 hash_value = i::V8::Random() & i::Smi::kMaxValue; | 2216 hash_value = i::V8::Random() & i::Smi::kMaxValue; |
2193 attempts++; | 2217 attempts++; |
2194 } while (hash_value == 0 && attempts < 30); | 2218 } while (hash_value == 0 && attempts < 30); |
2195 hash_value = hash_value != 0 ? hash_value : 1; // never return 0 | 2219 hash_value = hash_value != 0 ? hash_value : 1; // never return 0 |
2196 i::SetProperty(hidden_props, | 2220 i::SetProperty(hidden_props, |
2197 hash_symbol, | 2221 hash_symbol, |
2198 i::Handle<i::Object>(i::Smi::FromInt(hash_value)), | 2222 i::Handle<i::Object>(i::Smi::FromInt(hash_value)), |
2199 static_cast<PropertyAttributes>(None)); | 2223 static_cast<PropertyAttributes>(None)); |
2200 } | 2224 } |
2201 return hash_value; | 2225 return hash_value; |
2202 } | 2226 } |
2203 | 2227 |
2204 | 2228 |
2205 bool v8::Object::SetHiddenValue(v8::Handle<v8::String> key, | 2229 bool v8::Object::SetHiddenValue(v8::Handle<v8::String> key, |
2206 v8::Handle<v8::Value> value) { | 2230 v8::Handle<v8::Value> value) { |
2207 ON_BAILOUT("v8::Object::SetHiddenValue()", return false); | 2231 ON_BAILOUT("v8::Object::SetHiddenValue()", return false); |
2208 ENTER_V8; | 2232 ENTER_V8; |
| 2233 HandleScope scope; |
2209 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 2234 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
2210 i::Handle<i::Object> hidden_props(i::GetHiddenProperties(self, true)); | 2235 i::Handle<i::Object> hidden_props(i::GetHiddenProperties(self, true)); |
2211 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); | 2236 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); |
2212 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); | 2237 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); |
2213 EXCEPTION_PREAMBLE(); | 2238 EXCEPTION_PREAMBLE(); |
2214 i::Handle<i::Object> obj = i::SetProperty( | 2239 i::Handle<i::Object> obj = i::SetProperty( |
2215 hidden_props, | 2240 hidden_props, |
2216 key_obj, | 2241 key_obj, |
2217 value_obj, | 2242 value_obj, |
2218 static_cast<PropertyAttributes>(None)); | 2243 static_cast<PropertyAttributes>(None)); |
(...skipping 19 matching lines...) Expand all Loading... |
2238 if (result->IsUndefined()) { | 2263 if (result->IsUndefined()) { |
2239 return v8::Local<v8::Value>(); | 2264 return v8::Local<v8::Value>(); |
2240 } | 2265 } |
2241 return Utils::ToLocal(result); | 2266 return Utils::ToLocal(result); |
2242 } | 2267 } |
2243 | 2268 |
2244 | 2269 |
2245 bool v8::Object::DeleteHiddenValue(v8::Handle<v8::String> key) { | 2270 bool v8::Object::DeleteHiddenValue(v8::Handle<v8::String> key) { |
2246 ON_BAILOUT("v8::DeleteHiddenValue()", return false); | 2271 ON_BAILOUT("v8::DeleteHiddenValue()", return false); |
2247 ENTER_V8; | 2272 ENTER_V8; |
| 2273 HandleScope scope; |
2248 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 2274 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
2249 i::Handle<i::Object> hidden_props(i::GetHiddenProperties(self, false)); | 2275 i::Handle<i::Object> hidden_props(i::GetHiddenProperties(self, false)); |
2250 if (hidden_props->IsUndefined()) { | 2276 if (hidden_props->IsUndefined()) { |
2251 return true; | 2277 return true; |
2252 } | 2278 } |
2253 i::Handle<i::JSObject> js_obj(i::JSObject::cast(*hidden_props)); | 2279 i::Handle<i::JSObject> js_obj(i::JSObject::cast(*hidden_props)); |
2254 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); | 2280 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); |
2255 return i::DeleteProperty(js_obj, key_obj)->IsTrue(); | 2281 return i::DeleteProperty(js_obj, key_obj)->IsTrue(); |
2256 } | 2282 } |
2257 | 2283 |
2258 | 2284 |
2259 void v8::Object::SetIndexedPropertiesToPixelData(uint8_t* data, int length) { | 2285 void v8::Object::SetIndexedPropertiesToPixelData(uint8_t* data, int length) { |
2260 ON_BAILOUT("v8::SetElementsToPixelData()", return); | 2286 ON_BAILOUT("v8::SetElementsToPixelData()", return); |
2261 ENTER_V8; | 2287 ENTER_V8; |
| 2288 HandleScope scope; |
2262 if (!ApiCheck(i::Smi::IsValid(length), | 2289 if (!ApiCheck(i::Smi::IsValid(length), |
2263 "v8::Object::SetIndexedPropertiesToPixelData()", | 2290 "v8::Object::SetIndexedPropertiesToPixelData()", |
2264 "length exceeds max acceptable value")) { | 2291 "length exceeds max acceptable value")) { |
2265 return; | 2292 return; |
2266 } | 2293 } |
2267 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 2294 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
2268 if (!ApiCheck(!self->IsJSArray(), | 2295 if (!ApiCheck(!self->IsJSArray(), |
2269 "v8::Object::SetIndexedPropertiesToPixelData()", | 2296 "v8::Object::SetIndexedPropertiesToPixelData()", |
2270 "JSArray is not supported")) { | 2297 "JSArray is not supported")) { |
2271 return; | 2298 return; |
(...skipping 1460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3732 | 3759 |
3733 | 3760 |
3734 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { | 3761 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { |
3735 HandleScopeImplementer* thread_local = | 3762 HandleScopeImplementer* thread_local = |
3736 reinterpret_cast<HandleScopeImplementer*>(storage); | 3763 reinterpret_cast<HandleScopeImplementer*>(storage); |
3737 thread_local->IterateThis(v); | 3764 thread_local->IterateThis(v); |
3738 return storage + ArchiveSpacePerThread(); | 3765 return storage + ArchiveSpacePerThread(); |
3739 } | 3766 } |
3740 | 3767 |
3741 } } // namespace v8::internal | 3768 } } // namespace v8::internal |
OLD | NEW |