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

Side by Side Diff: src/objects-inl.h

Issue 151019: Changed the global object representation (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 5 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
OLDNEW
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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 PropertyDetails::PropertyDetails(Smi* smi) { 46 PropertyDetails::PropertyDetails(Smi* smi) {
47 value_ = smi->value(); 47 value_ = smi->value();
48 } 48 }
49 49
50 50
51 Smi* PropertyDetails::AsSmi() { 51 Smi* PropertyDetails::AsSmi() {
52 return Smi::FromInt(value_); 52 return Smi::FromInt(value_);
53 } 53 }
54 54
55 55
56 PropertyDetails PropertyDetails::AsDeleted() {
57 PropertyDetails d(DONT_ENUM, NORMAL);
58 Smi* smi = Smi::FromInt(AsSmi()->value() | DeletedField::encode(1));
59 return PropertyDetails(smi);
60 }
61
62
56 #define CAST_ACCESSOR(type) \ 63 #define CAST_ACCESSOR(type) \
57 type* type::cast(Object* object) { \ 64 type* type::cast(Object* object) { \
58 ASSERT(object->Is##type()); \ 65 ASSERT(object->Is##type()); \
59 return reinterpret_cast<type*>(object); \ 66 return reinterpret_cast<type*>(object); \
60 } 67 }
61 68
62 69
63 #define INT_ACCESSORS(holder, name, offset) \ 70 #define INT_ACCESSORS(holder, name, offset) \
64 int holder::name() { return READ_INT_FIELD(this, offset); } \ 71 int holder::name() { return READ_INT_FIELD(this, offset); } \
65 void holder::set_##name(int value) { WRITE_INT_FIELD(this, offset, value); } 72 void holder::set_##name(int value) { WRITE_INT_FIELD(this, offset, value); }
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 && HeapObject::cast(this)->map()->instance_type() == CODE_TYPE; 409 && HeapObject::cast(this)->map()->instance_type() == CODE_TYPE;
403 } 410 }
404 411
405 412
406 bool Object::IsOddball() { 413 bool Object::IsOddball() {
407 return Object::IsHeapObject() 414 return Object::IsHeapObject()
408 && HeapObject::cast(this)->map()->instance_type() == ODDBALL_TYPE; 415 && HeapObject::cast(this)->map()->instance_type() == ODDBALL_TYPE;
409 } 416 }
410 417
411 418
419 bool Object::IsJSGlobalPropertyCell() {
420 return Object::IsHeapObject()
421 && HeapObject::cast(this)->map()->instance_type()
422 == JS_GLOBAL_PROPERTY_CELL_TYPE;
423 }
424
425
412 bool Object::IsSharedFunctionInfo() { 426 bool Object::IsSharedFunctionInfo() {
413 return Object::IsHeapObject() && 427 return Object::IsHeapObject() &&
414 (HeapObject::cast(this)->map()->instance_type() == 428 (HeapObject::cast(this)->map()->instance_type() ==
415 SHARED_FUNCTION_INFO_TYPE); 429 SHARED_FUNCTION_INFO_TYPE);
416 } 430 }
417 431
418 432
419 bool Object::IsJSValue() { 433 bool Object::IsJSValue() {
420 return Object::IsHeapObject() 434 return Object::IsHeapObject()
421 && HeapObject::cast(this)->map()->instance_type() == JS_VALUE_TYPE; 435 && HeapObject::cast(this)->map()->instance_type() == JS_VALUE_TYPE;
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after
1033 void JSObject::initialize_elements() { 1047 void JSObject::initialize_elements() {
1034 ASSERT(!Heap::InNewSpace(Heap::empty_fixed_array())); 1048 ASSERT(!Heap::InNewSpace(Heap::empty_fixed_array()));
1035 WRITE_FIELD(this, kElementsOffset, Heap::empty_fixed_array()); 1049 WRITE_FIELD(this, kElementsOffset, Heap::empty_fixed_array());
1036 } 1050 }
1037 1051
1038 1052
1039 ACCESSORS(Oddball, to_string, String, kToStringOffset) 1053 ACCESSORS(Oddball, to_string, String, kToStringOffset)
1040 ACCESSORS(Oddball, to_number, Object, kToNumberOffset) 1054 ACCESSORS(Oddball, to_number, Object, kToNumberOffset)
1041 1055
1042 1056
1057 ACCESSORS(JSGlobalPropertyCell, value, Object, kValueOffset)
1058
1043 int JSObject::GetHeaderSize() { 1059 int JSObject::GetHeaderSize() {
1044 switch (map()->instance_type()) { 1060 switch (map()->instance_type()) {
1045 case JS_GLOBAL_PROXY_TYPE: 1061 case JS_GLOBAL_PROXY_TYPE:
1046 return JSGlobalProxy::kSize; 1062 return JSGlobalProxy::kSize;
1047 case JS_GLOBAL_OBJECT_TYPE: 1063 case JS_GLOBAL_OBJECT_TYPE:
1048 return JSGlobalObject::kSize; 1064 return JSGlobalObject::kSize;
1049 case JS_BUILTINS_OBJECT_TYPE: 1065 case JS_BUILTINS_OBJECT_TYPE:
1050 return JSBuiltinsObject::kSize; 1066 return JSBuiltinsObject::kSize;
1051 case JS_FUNCTION_TYPE: 1067 case JS_FUNCTION_TYPE:
1052 return JSFunction::kSize; 1068 return JSFunction::kSize;
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
1390 CAST_ACCESSOR(SlicedString) 1406 CAST_ACCESSOR(SlicedString)
1391 CAST_ACCESSOR(ExternalString) 1407 CAST_ACCESSOR(ExternalString)
1392 CAST_ACCESSOR(ExternalAsciiString) 1408 CAST_ACCESSOR(ExternalAsciiString)
1393 CAST_ACCESSOR(ExternalTwoByteString) 1409 CAST_ACCESSOR(ExternalTwoByteString)
1394 CAST_ACCESSOR(JSObject) 1410 CAST_ACCESSOR(JSObject)
1395 CAST_ACCESSOR(Smi) 1411 CAST_ACCESSOR(Smi)
1396 CAST_ACCESSOR(Failure) 1412 CAST_ACCESSOR(Failure)
1397 CAST_ACCESSOR(HeapObject) 1413 CAST_ACCESSOR(HeapObject)
1398 CAST_ACCESSOR(HeapNumber) 1414 CAST_ACCESSOR(HeapNumber)
1399 CAST_ACCESSOR(Oddball) 1415 CAST_ACCESSOR(Oddball)
1416 CAST_ACCESSOR(JSGlobalPropertyCell)
1400 CAST_ACCESSOR(SharedFunctionInfo) 1417 CAST_ACCESSOR(SharedFunctionInfo)
1401 CAST_ACCESSOR(Map) 1418 CAST_ACCESSOR(Map)
1402 CAST_ACCESSOR(JSFunction) 1419 CAST_ACCESSOR(JSFunction)
1403 CAST_ACCESSOR(GlobalObject) 1420 CAST_ACCESSOR(GlobalObject)
1404 CAST_ACCESSOR(JSGlobalProxy) 1421 CAST_ACCESSOR(JSGlobalProxy)
1405 CAST_ACCESSOR(JSGlobalObject) 1422 CAST_ACCESSOR(JSGlobalObject)
1406 CAST_ACCESSOR(JSBuiltinsObject) 1423 CAST_ACCESSOR(JSBuiltinsObject)
1407 CAST_ACCESSOR(Code) 1424 CAST_ACCESSOR(Code)
1408 CAST_ACCESSOR(JSArray) 1425 CAST_ACCESSOR(JSArray)
1409 CAST_ACCESSOR(JSRegExp) 1426 CAST_ACCESSOR(JSRegExp)
(...skipping 1265 matching lines...) Expand 10 before | Expand all | Expand 10 after
2675 #undef WRITE_INT_FIELD 2692 #undef WRITE_INT_FIELD
2676 #undef READ_SHORT_FIELD 2693 #undef READ_SHORT_FIELD
2677 #undef WRITE_SHORT_FIELD 2694 #undef WRITE_SHORT_FIELD
2678 #undef READ_BYTE_FIELD 2695 #undef READ_BYTE_FIELD
2679 #undef WRITE_BYTE_FIELD 2696 #undef WRITE_BYTE_FIELD
2680 2697
2681 2698
2682 } } // namespace v8::internal 2699 } } // namespace v8::internal
2683 2700
2684 #endif // V8_OBJECTS_INL_H_ 2701 #endif // V8_OBJECTS_INL_H_
OLDNEW
« no previous file with comments | « src/objects-debug.cc ('k') | src/property.h » ('j') | test/cctest/test-api.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698