| OLD | NEW |
| 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 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 #define READ_FIELD(p, offset) \ | 503 #define READ_FIELD(p, offset) \ |
| 504 (*reinterpret_cast<Object**>(FIELD_ADDR(p, offset))) | 504 (*reinterpret_cast<Object**>(FIELD_ADDR(p, offset))) |
| 505 | 505 |
| 506 #define WRITE_FIELD(p, offset, value) \ | 506 #define WRITE_FIELD(p, offset, value) \ |
| 507 (*reinterpret_cast<Object**>(FIELD_ADDR(p, offset)) = value) | 507 (*reinterpret_cast<Object**>(FIELD_ADDR(p, offset)) = value) |
| 508 | 508 |
| 509 | 509 |
| 510 #define WRITE_BARRIER(object, offset) \ | 510 #define WRITE_BARRIER(object, offset) \ |
| 511 Heap::RecordWrite(object->address(), offset); | 511 Heap::RecordWrite(object->address(), offset); |
| 512 | 512 |
| 513 // CONITIONAL_WRITE_BARRIER must be issued after the actual | 513 // CONDITIONAL_WRITE_BARRIER must be issued after the actual |
| 514 // write due to the assert validating the written value. | 514 // write due to the assert validating the written value. |
| 515 #define CONDITIONAL_WRITE_BARRIER(object, offset, mode) \ | 515 #define CONDITIONAL_WRITE_BARRIER(object, offset, mode) \ |
| 516 if (mode == UPDATE_WRITE_BARRIER) { \ | 516 if (mode == UPDATE_WRITE_BARRIER) { \ |
| 517 Heap::RecordWrite(object->address(), offset); \ | 517 Heap::RecordWrite(object->address(), offset); \ |
| 518 } else { \ | 518 } else { \ |
| 519 ASSERT(mode == SKIP_WRITE_BARRIER); \ | 519 ASSERT(mode == SKIP_WRITE_BARRIER); \ |
| 520 ASSERT(Heap::InNewSpace(object) || \ | 520 ASSERT(Heap::InNewSpace(object) || \ |
| 521 !Heap::InNewSpace(READ_FIELD(object, offset))); \ | 521 !Heap::InNewSpace(READ_FIELD(object, offset))); \ |
| 522 } | 522 } |
| 523 | 523 |
| (...skipping 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1527 | 1527 |
| 1528 return SizeFor(length); | 1528 return SizeFor(length); |
| 1529 } | 1529 } |
| 1530 | 1530 |
| 1531 | 1531 |
| 1532 Object* ConsString::first() { | 1532 Object* ConsString::first() { |
| 1533 return READ_FIELD(this, kFirstOffset); | 1533 return READ_FIELD(this, kFirstOffset); |
| 1534 } | 1534 } |
| 1535 | 1535 |
| 1536 | 1536 |
| 1537 void ConsString::set_first(Object* value) { | 1537 void ConsString::set_first(Object* value, WriteBarrierMode mode) { |
| 1538 WRITE_FIELD(this, kFirstOffset, value); | 1538 WRITE_FIELD(this, kFirstOffset, value); |
| 1539 WRITE_BARRIER(this, kFirstOffset); | 1539 CONDITIONAL_WRITE_BARRIER(this, kFirstOffset, mode); |
| 1540 } | 1540 } |
| 1541 | 1541 |
| 1542 | 1542 |
| 1543 Object* ConsString::second() { | 1543 Object* ConsString::second() { |
| 1544 return READ_FIELD(this, kSecondOffset); | 1544 return READ_FIELD(this, kSecondOffset); |
| 1545 } | 1545 } |
| 1546 | 1546 |
| 1547 | 1547 |
| 1548 void ConsString::set_second(Object* value) { | 1548 void ConsString::set_second(Object* value, WriteBarrierMode mode) { |
| 1549 WRITE_FIELD(this, kSecondOffset, value); | 1549 WRITE_FIELD(this, kSecondOffset, value); |
| 1550 WRITE_BARRIER(this, kSecondOffset); | 1550 CONDITIONAL_WRITE_BARRIER(this, kSecondOffset, mode); |
| 1551 } | 1551 } |
| 1552 | 1552 |
| 1553 | 1553 |
| 1554 Object* SlicedString::buffer() { | 1554 Object* SlicedString::buffer() { |
| 1555 return READ_FIELD(this, kBufferOffset); | 1555 return READ_FIELD(this, kBufferOffset); |
| 1556 } | 1556 } |
| 1557 | 1557 |
| 1558 | 1558 |
| 1559 void SlicedString::set_buffer(Object* buffer) { | 1559 void SlicedString::set_buffer(Object* buffer) { |
| 1560 WRITE_FIELD(this, kBufferOffset, buffer); | 1560 WRITE_FIELD(this, kBufferOffset, buffer); |
| (...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2064 if (map()->has_non_instance_prototype()) return map()->constructor(); | 2064 if (map()->has_non_instance_prototype()) return map()->constructor(); |
| 2065 return instance_prototype(); | 2065 return instance_prototype(); |
| 2066 } | 2066 } |
| 2067 | 2067 |
| 2068 | 2068 |
| 2069 bool JSFunction::is_compiled() { | 2069 bool JSFunction::is_compiled() { |
| 2070 return shared()->is_compiled(); | 2070 return shared()->is_compiled(); |
| 2071 } | 2071 } |
| 2072 | 2072 |
| 2073 | 2073 |
| 2074 int JSFunction::NumberOfLiterals() { |
| 2075 return literals()->length(); |
| 2076 } |
| 2077 |
| 2078 |
| 2074 Object* JSBuiltinsObject::javascript_builtin(Builtins::JavaScript id) { | 2079 Object* JSBuiltinsObject::javascript_builtin(Builtins::JavaScript id) { |
| 2075 ASSERT(0 <= id && id < kJSBuiltinsCount); | 2080 ASSERT(0 <= id && id < kJSBuiltinsCount); |
| 2076 return READ_FIELD(this, kJSBuiltinsOffset + (id * kPointerSize)); | 2081 return READ_FIELD(this, kJSBuiltinsOffset + (id * kPointerSize)); |
| 2077 } | 2082 } |
| 2078 | 2083 |
| 2079 | 2084 |
| 2080 void JSBuiltinsObject::set_javascript_builtin(Builtins::JavaScript id, | 2085 void JSBuiltinsObject::set_javascript_builtin(Builtins::JavaScript id, |
| 2081 Object* value) { | 2086 Object* value) { |
| 2082 ASSERT(0 <= id && id < kJSBuiltinsCount); | 2087 ASSERT(0 <= id && id < kJSBuiltinsCount); |
| 2083 WRITE_FIELD(this, kJSBuiltinsOffset + (id * kPointerSize), value); | 2088 WRITE_FIELD(this, kJSBuiltinsOffset + (id * kPointerSize), value); |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2344 void Map::ClearCodeCache() { | 2349 void Map::ClearCodeCache() { |
| 2345 // No write barrier is needed since empty_fixed_array is not in new space. | 2350 // No write barrier is needed since empty_fixed_array is not in new space. |
| 2346 // Please note this function is used during marking: | 2351 // Please note this function is used during marking: |
| 2347 // - MarkCompactCollector::MarkUnmarkedObject | 2352 // - MarkCompactCollector::MarkUnmarkedObject |
| 2348 ASSERT(!Heap::InNewSpace(Heap::empty_fixed_array())); | 2353 ASSERT(!Heap::InNewSpace(Heap::empty_fixed_array())); |
| 2349 WRITE_FIELD(this, kCodeCacheOffset, Heap::empty_fixed_array()); | 2354 WRITE_FIELD(this, kCodeCacheOffset, Heap::empty_fixed_array()); |
| 2350 } | 2355 } |
| 2351 | 2356 |
| 2352 | 2357 |
| 2353 void JSArray::SetContent(FixedArray* storage) { | 2358 void JSArray::SetContent(FixedArray* storage) { |
| 2354 set_length(Smi::FromInt(storage->length())); | 2359 set_length(Smi::FromInt(storage->length()), SKIP_WRITE_BARRIER); |
| 2355 set_elements(storage); | 2360 set_elements(storage); |
| 2356 } | 2361 } |
| 2357 | 2362 |
| 2358 | 2363 |
| 2359 Object* FixedArray::Copy() { | 2364 Object* FixedArray::Copy() { |
| 2360 if (length() == 0) return this; | 2365 if (length() == 0) return this; |
| 2361 return Heap::CopyFixedArray(this); | 2366 return Heap::CopyFixedArray(this); |
| 2362 } | 2367 } |
| 2363 | 2368 |
| 2364 | 2369 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2379 #undef WRITE_INT_FIELD | 2384 #undef WRITE_INT_FIELD |
| 2380 #undef READ_SHORT_FIELD | 2385 #undef READ_SHORT_FIELD |
| 2381 #undef WRITE_SHORT_FIELD | 2386 #undef WRITE_SHORT_FIELD |
| 2382 #undef READ_BYTE_FIELD | 2387 #undef READ_BYTE_FIELD |
| 2383 #undef WRITE_BYTE_FIELD | 2388 #undef WRITE_BYTE_FIELD |
| 2384 | 2389 |
| 2385 | 2390 |
| 2386 } } // namespace v8::internal | 2391 } } // namespace v8::internal |
| 2387 | 2392 |
| 2388 #endif // V8_OBJECTS_INL_H_ | 2393 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |