Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 92 | 92 |
| 93 | 93 |
| 94 static void CheckNumber(Isolate* isolate, double value, const char* string) { | 94 static void CheckNumber(Isolate* isolate, double value, const char* string) { |
| 95 Handle<Object> number = isolate->factory()->NewNumber(value); | 95 Handle<Object> number = isolate->factory()->NewNumber(value); |
| 96 CHECK(number->IsNumber()); | 96 CHECK(number->IsNumber()); |
| 97 Handle<Object> print_string = | 97 Handle<Object> print_string = |
| 98 Object::ToString(isolate, number).ToHandleChecked(); | 98 Object::ToString(isolate, number).ToHandleChecked(); |
| 99 CHECK(String::cast(*print_string)->IsUtf8EqualTo(CStrVector(string))); | 99 CHECK(String::cast(*print_string)->IsUtf8EqualTo(CStrVector(string))); |
| 100 } | 100 } |
| 101 | 101 |
| 102 AllocationResult TestCopyCode(Heap* heap, Code* code) { | |
| 103 return heap->CopyCode(code); | |
| 104 } | |
| 105 | |
| 106 void CheckEmbeddedObjectsAreEqual(Handle<Code> lhs, Handle<Code> rhs) { | |
| 107 int mode_mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT); | |
| 108 RelocIterator lhs_it(*lhs, mode_mask); | |
| 109 RelocIterator rhs_it(*rhs, mode_mask); | |
| 110 while (!lhs_it.done() && !rhs_it.done()) { | |
| 111 CHECK(lhs_it.rinfo()->target_object() == rhs_it.rinfo()->target_object()); | |
| 112 | |
| 113 lhs_it.next(); | |
| 114 rhs_it.next(); | |
| 115 } | |
| 116 CHECK(lhs_it.done() == rhs_it.done()); | |
| 117 } | |
| 118 | |
| 119 TEST(TestNewSpaceRefsInCopiedCode) { | |
| 120 CcTest::InitializeVM(); | |
| 121 Isolate* isolate = CcTest::i_isolate(); | |
| 122 Factory* factory = isolate->factory(); | |
| 123 Heap* heap = isolate->heap(); | |
| 124 HandleScope sc(isolate); | |
| 125 | |
| 126 Handle<Object> value = factory->NewNumber(1.000123); | |
|
Michael Lippautz
2016/08/02 19:07:58
CHECK for object being in new space
ahaas
2016/08/03 08:47:42
Done.
| |
| 127 | |
| 128 i::byte buffer[i::Assembler::kMinimalBufferSize]; | |
| 129 MacroAssembler masm(isolate, buffer, sizeof(buffer), | |
| 130 v8::internal::CodeObjectRequired::kYes); | |
| 131 // Add a new-space reference to the code. | |
| 132 masm.Push(value); | |
| 133 | |
| 134 CodeDesc desc; | |
| 135 masm.GetCode(&desc); | |
| 136 Handle<Code> code = isolate->factory()->NewCode( | |
|
Michael Lippautz
2016/08/02 19:07:57
Cool stuff!
| |
| 137 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | |
| 138 | |
| 139 Code* tmp; | |
| 140 TestCopyCode(heap, *code).To(&tmp); | |
| 141 Handle<Code> copy(tmp); | |
| 142 | |
| 143 CheckEmbeddedObjectsAreEqual(code, copy); | |
| 144 heap->CollectAllAvailableGarbage(); | |
| 145 CheckEmbeddedObjectsAreEqual(code, copy); | |
| 146 } | |
| 102 | 147 |
| 103 static void CheckFindCodeObject(Isolate* isolate) { | 148 static void CheckFindCodeObject(Isolate* isolate) { |
| 104 // Test FindCodeObject | 149 // Test FindCodeObject |
| 105 #define __ assm. | 150 #define __ assm. |
| 106 | 151 |
| 107 Assembler assm(isolate, NULL, 0); | 152 Assembler assm(isolate, NULL, 0); |
| 108 | 153 |
| 109 __ nop(); // supported on all architectures | 154 __ nop(); // supported on all architectures |
| 110 | 155 |
| 111 CodeDesc desc; | 156 CodeDesc desc; |
| (...skipping 6931 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7043 chunk, chunk->area_end() - kPointerSize, chunk->area_end()); | 7088 chunk, chunk->area_end() - kPointerSize, chunk->area_end()); |
| 7044 slots[chunk->area_end() - kPointerSize] = false; | 7089 slots[chunk->area_end() - kPointerSize] = false; |
| 7045 RememberedSet<OLD_TO_NEW>::Iterate(chunk, [&slots](Address addr) { | 7090 RememberedSet<OLD_TO_NEW>::Iterate(chunk, [&slots](Address addr) { |
| 7046 CHECK(slots[addr]); | 7091 CHECK(slots[addr]); |
| 7047 return KEEP_SLOT; | 7092 return KEEP_SLOT; |
| 7048 }); | 7093 }); |
| 7049 } | 7094 } |
| 7050 | 7095 |
| 7051 } // namespace internal | 7096 } // namespace internal |
| 7052 } // namespace v8 | 7097 } // namespace v8 |
| OLD | NEW |