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

Side by Side Diff: src/api.cc

Issue 50016: Allow hidden properties and implement GetIdentityHash (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 9 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 | « include/v8.h ('k') | src/factory.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 2007-2008 the V8 project authors. All rights reserved. 1 // Copyright 2007-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 1912 matching lines...) Expand 10 before | Expand all | Expand 10 after
1923 ON_BAILOUT("v8::Object::Clone()", return Local<Object>()); 1923 ON_BAILOUT("v8::Object::Clone()", return Local<Object>());
1924 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 1924 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
1925 EXCEPTION_PREAMBLE(); 1925 EXCEPTION_PREAMBLE();
1926 i::Handle<i::JSObject> result = i::Copy(self); 1926 i::Handle<i::JSObject> result = i::Copy(self);
1927 has_pending_exception = result.is_null(); 1927 has_pending_exception = result.is_null();
1928 EXCEPTION_BAILOUT_CHECK(Local<Object>()); 1928 EXCEPTION_BAILOUT_CHECK(Local<Object>());
1929 return Utils::ToLocal(result); 1929 return Utils::ToLocal(result);
1930 } 1930 }
1931 1931
1932 1932
1933 int v8::Object::GetIdentityHash() {
1934 ON_BAILOUT("v8::Object::GetIdentityHash()", return 0);
1935 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
1936 i::Handle<i::Object> hidden_props(i::GetHiddenProperties(self, true));
1937 i::Handle<i::Object> hash_symbol = i::Factory::identity_hash_symbol();
1938 i::Handle<i::Object> hash = i::GetProperty(hidden_props, hash_symbol);
1939 int hash_value;
1940 if (hash->IsSmi()) {
1941 hash_value = i::Smi::cast(*hash)->value();
1942 } else {
1943 hash_value = random() & i::Smi::kMaxValue; // Limit range to fit a smi.
1944 i::SetProperty(hidden_props,
1945 hash_symbol,
1946 i::Handle<i::Object>(i::Smi::FromInt(hash_value)),
1947 static_cast<PropertyAttributes>(None));
1948 }
1949 return hash_value;
1950 }
1951
1952
1953 bool v8::Object::SetHiddenValue(v8::Handle<v8::String> key,
1954 v8::Handle<v8::Value> value) {
1955 ON_BAILOUT("v8::Object::SetHiddenValue()", return false);
1956 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
1957 i::Handle<i::Object> hidden_props(i::GetHiddenProperties(self, true));
1958 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key);
1959 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value);
1960 EXCEPTION_PREAMBLE();
1961 i::Handle<i::Object> obj = i::SetProperty(
1962 hidden_props,
1963 key_obj,
1964 value_obj,
1965 static_cast<PropertyAttributes>(None));
1966 has_pending_exception = obj.is_null();
1967 EXCEPTION_BAILOUT_CHECK(false);
1968 return true;
1969 }
1970
1971
1972 v8::Local<v8::Value> v8::Object::GetHiddenValue(v8::Handle<v8::String> key) {
1973 ON_BAILOUT("v8::Object::GetHiddenValue()", return Local<v8::Value>());
1974 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
1975 i::Handle<i::Object> hidden_props(i::GetHiddenProperties(self, false));
1976 if (hidden_props->IsUndefined()) {
1977 return v8::Local<v8::Value>();
1978 }
1979 i::Handle<i::String> key_obj = Utils::OpenHandle(*key);
1980 EXCEPTION_PREAMBLE();
1981 i::Handle<i::Object> result = i::GetProperty(hidden_props, key_obj);
1982 has_pending_exception = result.is_null();
1983 EXCEPTION_BAILOUT_CHECK(v8::Local<v8::Value>());
1984 if (result->IsUndefined()) {
1985 return v8::Local<v8::Value>();
1986 }
1987 return Utils::ToLocal(result);
1988 }
1989
1990
1991 bool v8::Object::DeleteHiddenValue(v8::Handle<v8::String> key) {
1992 ON_BAILOUT("v8::DeleteHiddenValue()", return false);
1993 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
1994 i::Handle<i::JSObject> hidden_props(
1995 i::JSObject::cast(*i::GetHiddenProperties(self, false)));
1996 if (hidden_props->IsUndefined()) {
1997 return false;
1998 }
1999 i::Handle<i::String> key_obj = Utils::OpenHandle(*key);
2000 return i::DeleteProperty(hidden_props, key_obj)->IsTrue();
2001 }
2002
2003
1933 Local<v8::Object> Function::NewInstance() const { 2004 Local<v8::Object> Function::NewInstance() const {
1934 return NewInstance(0, NULL); 2005 return NewInstance(0, NULL);
1935 } 2006 }
1936 2007
1937 2008
1938 Local<v8::Object> Function::NewInstance(int argc, 2009 Local<v8::Object> Function::NewInstance(int argc,
1939 v8::Handle<v8::Value> argv[]) const { 2010 v8::Handle<v8::Value> argv[]) const {
1940 ON_BAILOUT("v8::Function::NewInstance()", return Local<v8::Object>()); 2011 ON_BAILOUT("v8::Function::NewInstance()", return Local<v8::Object>());
1941 LOG_API("Function::NewInstance"); 2012 LOG_API("Function::NewInstance");
1942 HandleScope scope; 2013 HandleScope scope;
(...skipping 1130 matching lines...) Expand 10 before | Expand all | Expand 10 after
3073 reinterpret_cast<HandleScopeImplementer*>(storage); 3144 reinterpret_cast<HandleScopeImplementer*>(storage);
3074 List<void**>* blocks_of_archived_thread = thread_local->Blocks(); 3145 List<void**>* blocks_of_archived_thread = thread_local->Blocks();
3075 v8::ImplementationUtilities::HandleScopeData* handle_data_of_archived_thread = 3146 v8::ImplementationUtilities::HandleScopeData* handle_data_of_archived_thread =
3076 &thread_local->handle_scope_data_; 3147 &thread_local->handle_scope_data_;
3077 Iterate(v, blocks_of_archived_thread, handle_data_of_archived_thread); 3148 Iterate(v, blocks_of_archived_thread, handle_data_of_archived_thread);
3078 3149
3079 return storage + ArchiveSpacePerThread(); 3150 return storage + ArchiveSpacePerThread();
3080 } 3151 }
3081 3152
3082 } } // namespace v8::internal 3153 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « include/v8.h ('k') | src/factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698