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

Side by Side Diff: src/objects.cc

Issue 1413463006: Map v8::Object to v8::internal::JSReceiver (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates Created 5 years, 1 month 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 | « src/objects.h ('k') | test/cctest/compiler/function-tester.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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/objects.h" 5 #include "src/objects.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <iomanip> 8 #include <iomanip>
9 #include <sstream> 9 #include <sstream>
10 10
(...skipping 2231 matching lines...) Expand 10 before | Expand all | Expand 10 after
2242 // If the constructor is not present, return "Object". 2242 // If the constructor is not present, return "Object".
2243 return GetHeap()->Object_string(); 2243 return GetHeap()->Object_string();
2244 } 2244 }
2245 2245
2246 2246
2247 String* JSReceiver::constructor_name() { 2247 String* JSReceiver::constructor_name() {
2248 return map()->constructor_name(); 2248 return map()->constructor_name();
2249 } 2249 }
2250 2250
2251 2251
2252 Context* JSReceiver::GetCreationContext() {
2253 Object* constructor = map()->GetConstructor();
2254 JSFunction* function;
2255 if (!constructor->IsJSFunction()) {
2256 // Functions have null as a constructor,
2257 // but any JSFunction knows its context immediately.
2258 function = JSFunction::cast(this);
2259 } else {
2260 function = JSFunction::cast(constructor);
2261 }
2262
2263 return function->context()->native_context();
2264 }
2265
2266
2252 static Handle<Object> WrapType(Handle<HeapType> type) { 2267 static Handle<Object> WrapType(Handle<HeapType> type) {
2253 if (type->IsClass()) return Map::WeakCellForMap(type->AsClass()->Map()); 2268 if (type->IsClass()) return Map::WeakCellForMap(type->AsClass()->Map());
2254 return type; 2269 return type;
2255 } 2270 }
2256 2271
2257 2272
2258 MaybeHandle<Map> Map::CopyWithField(Handle<Map> map, 2273 MaybeHandle<Map> Map::CopyWithField(Handle<Map> map,
2259 Handle<Name> name, 2274 Handle<Name> name,
2260 Handle<HeapType> type, 2275 Handle<HeapType> type,
2261 PropertyAttributes attributes, 2276 PropertyAttributes attributes,
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
2346 } else { 2361 } else {
2347 Handle<NameDictionary> dict(object->property_dictionary()); 2362 Handle<NameDictionary> dict(object->property_dictionary());
2348 PropertyDetails details(attributes, DATA, 0, PropertyCellType::kNoCell); 2363 PropertyDetails details(attributes, DATA, 0, PropertyCellType::kNoCell);
2349 Handle<NameDictionary> result = 2364 Handle<NameDictionary> result =
2350 NameDictionary::Add(dict, name, value, details); 2365 NameDictionary::Add(dict, name, value, details);
2351 if (*dict != *result) object->set_properties(*result); 2366 if (*dict != *result) object->set_properties(*result);
2352 } 2367 }
2353 } 2368 }
2354 2369
2355 2370
2356 Context* JSObject::GetCreationContext() {
2357 Object* constructor = this->map()->GetConstructor();
2358 JSFunction* function;
2359 if (!constructor->IsJSFunction()) {
2360 // Functions have null as a constructor,
2361 // but any JSFunction knows its context immediately.
2362 function = JSFunction::cast(this);
2363 } else {
2364 function = JSFunction::cast(constructor);
2365 }
2366
2367 return function->context()->native_context();
2368 }
2369
2370
2371 MaybeHandle<Object> JSObject::EnqueueChangeRecord(Handle<JSObject> object, 2371 MaybeHandle<Object> JSObject::EnqueueChangeRecord(Handle<JSObject> object,
2372 const char* type_str, 2372 const char* type_str,
2373 Handle<Name> name, 2373 Handle<Name> name,
2374 Handle<Object> old_value) { 2374 Handle<Object> old_value) {
2375 DCHECK(!object->IsJSGlobalProxy()); 2375 DCHECK(!object->IsJSGlobalProxy());
2376 DCHECK(!object->IsJSGlobalObject()); 2376 DCHECK(!object->IsJSGlobalObject());
2377 Isolate* isolate = object->GetIsolate(); 2377 Isolate* isolate = object->GetIsolate();
2378 HandleScope scope(isolate); 2378 HandleScope scope(isolate);
2379 Handle<String> type = isolate->factory()->InternalizeUtf8String(type_str); 2379 Handle<String> type = isolate->factory()->InternalizeUtf8String(type_str);
2380 Handle<Object> args[] = { type, object, name, old_value }; 2380 Handle<Object> args[] = { type, object, name, old_value };
(...skipping 4107 matching lines...) Expand 10 before | Expand all | Expand 10 after
6488 JSObject::DefineAccessor(it, getter, setter, attrs); 6488 JSObject::DefineAccessor(it, getter, setter, attrs);
6489 if (result.is_null()) return false; 6489 if (result.is_null()) return false;
6490 } 6490 }
6491 } 6491 }
6492 6492
6493 // 11. Return true. 6493 // 11. Return true.
6494 return true; 6494 return true;
6495 } 6495 }
6496 6496
6497 6497
6498 // static
6499 Maybe<bool> JSReceiver::CreateDataProperty(LookupIterator* it,
6500 Handle<Object> value) {
6501 // TODO(rossberg): Support proxies.
6502 if (!it->GetReceiver()->IsJSObject()) return Nothing<bool>();
6503 return JSObject::CreateDataProperty(it, value);
6504 }
6505
6506
6498 // TODO(jkummerow): Consider unification with FastAsArrayLength() in 6507 // TODO(jkummerow): Consider unification with FastAsArrayLength() in
6499 // accessors.cc. 6508 // accessors.cc.
6500 bool PropertyKeyToArrayLength(Handle<Object> value, uint32_t* length) { 6509 bool PropertyKeyToArrayLength(Handle<Object> value, uint32_t* length) {
6501 DCHECK(value->IsNumber() || value->IsName()); 6510 DCHECK(value->IsNumber() || value->IsName());
6502 if (value->ToArrayLength(length)) return true; 6511 if (value->ToArrayLength(length)) return true;
6503 if (value->IsString()) return String::cast(*value)->AsArrayIndex(length); 6512 if (value->IsString()) return String::cast(*value)->AsArrayIndex(length);
6504 return false; 6513 return false;
6505 } 6514 }
6506 6515
6507 6516
(...skipping 8353 matching lines...) Expand 10 before | Expand all | Expand 10 after
14861 v8::Local<v8::Object> result; 14870 v8::Local<v8::Object> result;
14862 if (!interceptor->enumerator()->IsUndefined()) { 14871 if (!interceptor->enumerator()->IsUndefined()) {
14863 v8::GenericNamedPropertyEnumeratorCallback enum_fun = 14872 v8::GenericNamedPropertyEnumeratorCallback enum_fun =
14864 v8::ToCData<v8::GenericNamedPropertyEnumeratorCallback>( 14873 v8::ToCData<v8::GenericNamedPropertyEnumeratorCallback>(
14865 interceptor->enumerator()); 14874 interceptor->enumerator());
14866 LOG(isolate, ApiObjectAccess("interceptor-named-enum", *object)); 14875 LOG(isolate, ApiObjectAccess("interceptor-named-enum", *object));
14867 result = args.Call(enum_fun); 14876 result = args.Call(enum_fun);
14868 } 14877 }
14869 if (result.IsEmpty()) return MaybeHandle<JSObject>(); 14878 if (result.IsEmpty()) return MaybeHandle<JSObject>();
14870 DCHECK(v8::Utils::OpenHandle(*result)->IsJSArray() || 14879 DCHECK(v8::Utils::OpenHandle(*result)->IsJSArray() ||
14871 v8::Utils::OpenHandle(*result)->HasSloppyArgumentsElements()); 14880 (v8::Utils::OpenHandle(*result)->IsJSObject() &&
14881 Handle<JSObject>::cast(v8::Utils::OpenHandle(*result))
14882 ->HasSloppyArgumentsElements()));
14872 // Rebox before returning. 14883 // Rebox before returning.
14873 return handle(*v8::Utils::OpenHandle(*result), isolate); 14884 return handle(JSObject::cast(*v8::Utils::OpenHandle(*result)), isolate);
14874 } 14885 }
14875 14886
14876 14887
14877 // Compute the element keys from the interceptor. 14888 // Compute the element keys from the interceptor.
14878 MaybeHandle<JSObject> JSObject::GetKeysForIndexedInterceptor( 14889 MaybeHandle<JSObject> JSObject::GetKeysForIndexedInterceptor(
14879 Handle<JSObject> object, Handle<JSReceiver> receiver) { 14890 Handle<JSObject> object, Handle<JSReceiver> receiver) {
14880 Isolate* isolate = receiver->GetIsolate(); 14891 Isolate* isolate = receiver->GetIsolate();
14881 Handle<InterceptorInfo> interceptor(object->GetIndexedInterceptor()); 14892 Handle<InterceptorInfo> interceptor(object->GetIndexedInterceptor());
14882 PropertyCallbackArguments 14893 PropertyCallbackArguments
14883 args(isolate, interceptor->data(), *receiver, *object); 14894 args(isolate, interceptor->data(), *receiver, *object);
14884 v8::Local<v8::Object> result; 14895 v8::Local<v8::Object> result;
14885 if (!interceptor->enumerator()->IsUndefined()) { 14896 if (!interceptor->enumerator()->IsUndefined()) {
14886 v8::IndexedPropertyEnumeratorCallback enum_fun = 14897 v8::IndexedPropertyEnumeratorCallback enum_fun =
14887 v8::ToCData<v8::IndexedPropertyEnumeratorCallback>( 14898 v8::ToCData<v8::IndexedPropertyEnumeratorCallback>(
14888 interceptor->enumerator()); 14899 interceptor->enumerator());
14889 LOG(isolate, ApiObjectAccess("interceptor-indexed-enum", *object)); 14900 LOG(isolate, ApiObjectAccess("interceptor-indexed-enum", *object));
14890 result = args.Call(enum_fun); 14901 result = args.Call(enum_fun);
14891 } 14902 }
14892 if (result.IsEmpty()) return MaybeHandle<JSObject>(); 14903 if (result.IsEmpty()) return MaybeHandle<JSObject>();
14893 DCHECK(v8::Utils::OpenHandle(*result)->IsJSArray() || 14904 DCHECK(v8::Utils::OpenHandle(*result)->IsJSArray() ||
14894 v8::Utils::OpenHandle(*result)->HasSloppyArgumentsElements()); 14905 (v8::Utils::OpenHandle(*result)->IsJSObject() &&
14906 Handle<JSObject>::cast(v8::Utils::OpenHandle(*result))
14907 ->HasSloppyArgumentsElements()));
14895 // Rebox before returning. 14908 // Rebox before returning.
14896 return handle(*v8::Utils::OpenHandle(*result), isolate); 14909 return handle(JSObject::cast(*v8::Utils::OpenHandle(*result)), isolate);
14897 } 14910 }
14898 14911
14899 14912
14900 Maybe<bool> JSObject::HasRealNamedProperty(Handle<JSObject> object, 14913 Maybe<bool> JSObject::HasRealNamedProperty(Handle<JSObject> object,
14901 Handle<Name> name) { 14914 Handle<Name> name) {
14902 LookupIterator it = LookupIterator::PropertyOrElement( 14915 LookupIterator it = LookupIterator::PropertyOrElement(
14903 name->GetIsolate(), object, name, LookupIterator::OWN_SKIP_INTERCEPTOR); 14916 name->GetIsolate(), object, name, LookupIterator::OWN_SKIP_INTERCEPTOR);
14904 return HasProperty(&it); 14917 return HasProperty(&it);
14905 } 14918 }
14906 14919
(...skipping 3202 matching lines...) Expand 10 before | Expand all | Expand 10 after
18109 if (cell->value() != *new_value) { 18122 if (cell->value() != *new_value) {
18110 cell->set_value(*new_value); 18123 cell->set_value(*new_value);
18111 Isolate* isolate = cell->GetIsolate(); 18124 Isolate* isolate = cell->GetIsolate();
18112 cell->dependent_code()->DeoptimizeDependentCodeGroup( 18125 cell->dependent_code()->DeoptimizeDependentCodeGroup(
18113 isolate, DependentCode::kPropertyCellChangedGroup); 18126 isolate, DependentCode::kPropertyCellChangedGroup);
18114 } 18127 }
18115 } 18128 }
18116 18129
18117 } // namespace internal 18130 } // namespace internal
18118 } // namespace v8 18131 } // namespace v8
OLDNEW
« no previous file with comments | « src/objects.h ('k') | test/cctest/compiler/function-tester.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698