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

Side by Side Diff: src/api.cc

Issue 245024: API: added a few missing HandleScope-s. (Closed)
Patch Set: Created 11 years, 2 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
« no previous file with comments | « include/v8.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
2145 Handle<Value> v8::Object::GetRealNamedProperty(Handle<String> key) { 2148 Local<Value> v8::Object::GetRealNamedProperty(Handle<String> key) {
2146 ON_BAILOUT("v8::Object::GetRealNamedProperty()", return Local<Value>()); 2149 ON_BAILOUT("v8::Object::GetRealNamedProperty()", return Local<Value>());
2147 ENTER_V8; 2150 ENTER_V8;
2148 i::Handle<i::JSObject> self_obj = Utils::OpenHandle(this); 2151 i::Handle<i::JSObject> self_obj = Utils::OpenHandle(this);
2149 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); 2152 i::Handle<i::String> key_obj = Utils::OpenHandle(*key);
2150 i::LookupResult lookup; 2153 i::LookupResult lookup;
2151 self_obj->LookupRealNamedProperty(*key_obj, &lookup); 2154 self_obj->LookupRealNamedProperty(*key_obj, &lookup);
2152 if (lookup.IsValid()) { 2155 if (lookup.IsValid()) {
2153 PropertyAttributes attributes; 2156 PropertyAttributes attributes;
2154 i::Handle<i::Object> result(self_obj->GetProperty(*self_obj, 2157 i::Handle<i::Object> result(self_obj->GetProperty(*self_obj,
2155 &lookup, 2158 &lookup,
2156 *key_obj, 2159 *key_obj,
2157 &attributes)); 2160 &attributes));
2158 return Utils::ToLocal(result); 2161 return Utils::ToLocal(result);
2159 } 2162 }
2160 return Local<Value>(); // No real property was found in prototype chain. 2163 return Local<Value>(); // No real property was found in prototype chain.
2161 } 2164 }
2162 2165
2163 2166
2164 // 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.
2165 // Because the object gets a new map, existing inline cache caching 2168 // Because the object gets a new map, existing inline cache caching
2166 // the old map of this object will fail. 2169 // the old map of this object will fail.
2167 void v8::Object::TurnOnAccessCheck() { 2170 void v8::Object::TurnOnAccessCheck() {
2168 ON_BAILOUT("v8::Object::TurnOnAccessCheck()", return); 2171 ON_BAILOUT("v8::Object::TurnOnAccessCheck()", return);
2169 ENTER_V8; 2172 ENTER_V8;
2173 HandleScope scope;
2170 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); 2174 i::Handle<i::JSObject> obj = Utils::OpenHandle(this);
2171 2175
2172 i::Handle<i::Map> new_map = 2176 i::Handle<i::Map> new_map =
2173 i::Factory::CopyMapDropTransitions(i::Handle<i::Map>(obj->map())); 2177 i::Factory::CopyMapDropTransitions(i::Handle<i::Map>(obj->map()));
2174 new_map->set_is_access_check_needed(true); 2178 new_map->set_is_access_check_needed(true);
2175 obj->set_map(*new_map); 2179 obj->set_map(*new_map);
2176 } 2180 }
2177 2181
2178 2182
2179 bool v8::Object::IsDirty() { 2183 bool v8::Object::IsDirty() {
2180 return Utils::OpenHandle(this)->IsDirty(); 2184 return Utils::OpenHandle(this)->IsDirty();
2181 } 2185 }
2182 2186
2183 2187
2184 Local<v8::Object> v8::Object::Clone() { 2188 Local<v8::Object> v8::Object::Clone() {
2185 ON_BAILOUT("v8::Object::Clone()", return Local<Object>()); 2189 ON_BAILOUT("v8::Object::Clone()", return Local<Object>());
2186 ENTER_V8; 2190 ENTER_V8;
2187 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 2191 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
2188 EXCEPTION_PREAMBLE(); 2192 EXCEPTION_PREAMBLE();
2189 i::Handle<i::JSObject> result = i::Copy(self); 2193 i::Handle<i::JSObject> result = i::Copy(self);
2190 has_pending_exception = result.is_null(); 2194 has_pending_exception = result.is_null();
2191 EXCEPTION_BAILOUT_CHECK(Local<Object>()); 2195 EXCEPTION_BAILOUT_CHECK(Local<Object>());
2192 return Utils::ToLocal(result); 2196 return Utils::ToLocal(result);
2193 } 2197 }
2194 2198
2195 2199
2196 int v8::Object::GetIdentityHash() { 2200 int v8::Object::GetIdentityHash() {
2197 ON_BAILOUT("v8::Object::GetIdentityHash()", return 0); 2201 ON_BAILOUT("v8::Object::GetIdentityHash()", return 0);
2198 ENTER_V8; 2202 ENTER_V8;
2203 HandleScope scope;
2199 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 2204 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
2200 i::Handle<i::Object> hidden_props(i::GetHiddenProperties(self, true)); 2205 i::Handle<i::Object> hidden_props(i::GetHiddenProperties(self, true));
2201 i::Handle<i::Object> hash_symbol = i::Factory::identity_hash_symbol(); 2206 i::Handle<i::Object> hash_symbol = i::Factory::identity_hash_symbol();
2202 i::Handle<i::Object> hash = i::GetProperty(hidden_props, hash_symbol); 2207 i::Handle<i::Object> hash = i::GetProperty(hidden_props, hash_symbol);
2203 int hash_value; 2208 int hash_value;
2204 if (hash->IsSmi()) { 2209 if (hash->IsSmi()) {
2205 hash_value = i::Smi::cast(*hash)->value(); 2210 hash_value = i::Smi::cast(*hash)->value();
2206 } else { 2211 } else {
2207 int attempts = 0; 2212 int attempts = 0;
2208 do { 2213 do {
2209 // 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
2210 // within a smi. 2215 // within a smi.
2211 hash_value = i::V8::Random() & i::Smi::kMaxValue; 2216 hash_value = i::V8::Random() & i::Smi::kMaxValue;
2212 attempts++; 2217 attempts++;
2213 } while (hash_value == 0 && attempts < 30); 2218 } while (hash_value == 0 && attempts < 30);
2214 hash_value = hash_value != 0 ? hash_value : 1; // never return 0 2219 hash_value = hash_value != 0 ? hash_value : 1; // never return 0
2215 i::SetProperty(hidden_props, 2220 i::SetProperty(hidden_props,
2216 hash_symbol, 2221 hash_symbol,
2217 i::Handle<i::Object>(i::Smi::FromInt(hash_value)), 2222 i::Handle<i::Object>(i::Smi::FromInt(hash_value)),
2218 static_cast<PropertyAttributes>(None)); 2223 static_cast<PropertyAttributes>(None));
2219 } 2224 }
2220 return hash_value; 2225 return hash_value;
2221 } 2226 }
2222 2227
2223 2228
2224 bool v8::Object::SetHiddenValue(v8::Handle<v8::String> key, 2229 bool v8::Object::SetHiddenValue(v8::Handle<v8::String> key,
2225 v8::Handle<v8::Value> value) { 2230 v8::Handle<v8::Value> value) {
2226 ON_BAILOUT("v8::Object::SetHiddenValue()", return false); 2231 ON_BAILOUT("v8::Object::SetHiddenValue()", return false);
2227 ENTER_V8; 2232 ENTER_V8;
2233 HandleScope scope;
2228 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 2234 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
2229 i::Handle<i::Object> hidden_props(i::GetHiddenProperties(self, true)); 2235 i::Handle<i::Object> hidden_props(i::GetHiddenProperties(self, true));
2230 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); 2236 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key);
2231 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); 2237 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value);
2232 EXCEPTION_PREAMBLE(); 2238 EXCEPTION_PREAMBLE();
2233 i::Handle<i::Object> obj = i::SetProperty( 2239 i::Handle<i::Object> obj = i::SetProperty(
2234 hidden_props, 2240 hidden_props,
2235 key_obj, 2241 key_obj,
2236 value_obj, 2242 value_obj,
2237 static_cast<PropertyAttributes>(None)); 2243 static_cast<PropertyAttributes>(None));
(...skipping 19 matching lines...) Expand all
2257 if (result->IsUndefined()) { 2263 if (result->IsUndefined()) {
2258 return v8::Local<v8::Value>(); 2264 return v8::Local<v8::Value>();
2259 } 2265 }
2260 return Utils::ToLocal(result); 2266 return Utils::ToLocal(result);
2261 } 2267 }
2262 2268
2263 2269
2264 bool v8::Object::DeleteHiddenValue(v8::Handle<v8::String> key) { 2270 bool v8::Object::DeleteHiddenValue(v8::Handle<v8::String> key) {
2265 ON_BAILOUT("v8::DeleteHiddenValue()", return false); 2271 ON_BAILOUT("v8::DeleteHiddenValue()", return false);
2266 ENTER_V8; 2272 ENTER_V8;
2273 HandleScope scope;
2267 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 2274 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
2268 i::Handle<i::Object> hidden_props(i::GetHiddenProperties(self, false)); 2275 i::Handle<i::Object> hidden_props(i::GetHiddenProperties(self, false));
2269 if (hidden_props->IsUndefined()) { 2276 if (hidden_props->IsUndefined()) {
2270 return true; 2277 return true;
2271 } 2278 }
2272 i::Handle<i::JSObject> js_obj(i::JSObject::cast(*hidden_props)); 2279 i::Handle<i::JSObject> js_obj(i::JSObject::cast(*hidden_props));
2273 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); 2280 i::Handle<i::String> key_obj = Utils::OpenHandle(*key);
2274 return i::DeleteProperty(js_obj, key_obj)->IsTrue(); 2281 return i::DeleteProperty(js_obj, key_obj)->IsTrue();
2275 } 2282 }
2276 2283
2277 2284
2278 void v8::Object::SetIndexedPropertiesToPixelData(uint8_t* data, int length) { 2285 void v8::Object::SetIndexedPropertiesToPixelData(uint8_t* data, int length) {
2279 ON_BAILOUT("v8::SetElementsToPixelData()", return); 2286 ON_BAILOUT("v8::SetElementsToPixelData()", return);
2280 ENTER_V8; 2287 ENTER_V8;
2288 HandleScope scope;
2281 if (!ApiCheck(i::Smi::IsValid(length), 2289 if (!ApiCheck(i::Smi::IsValid(length),
2282 "v8::Object::SetIndexedPropertiesToPixelData()", 2290 "v8::Object::SetIndexedPropertiesToPixelData()",
2283 "length exceeds max acceptable value")) { 2291 "length exceeds max acceptable value")) {
2284 return; 2292 return;
2285 } 2293 }
2286 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 2294 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
2287 if (!ApiCheck(!self->IsJSArray(), 2295 if (!ApiCheck(!self->IsJSArray(),
2288 "v8::Object::SetIndexedPropertiesToPixelData()", 2296 "v8::Object::SetIndexedPropertiesToPixelData()",
2289 "JSArray is not supported")) { 2297 "JSArray is not supported")) {
2290 return; 2298 return;
(...skipping 1462 matching lines...) Expand 10 before | Expand all | Expand 10 after
3753 3761
3754 3762
3755 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { 3763 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) {
3756 HandleScopeImplementer* thread_local = 3764 HandleScopeImplementer* thread_local =
3757 reinterpret_cast<HandleScopeImplementer*>(storage); 3765 reinterpret_cast<HandleScopeImplementer*>(storage);
3758 thread_local->IterateThis(v); 3766 thread_local->IterateThis(v);
3759 return storage + ArchiveSpacePerThread(); 3767 return storage + ArchiveSpacePerThread();
3760 } 3768 }
3761 3769
3762 } } // namespace v8::internal 3770 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « include/v8.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698