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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 CheckMap(heap->meta_map(), MAP_TYPE, Map::kSize); | 69 CheckMap(heap->meta_map(), MAP_TYPE, Map::kSize); |
70 CheckMap(heap->heap_number_map(), HEAP_NUMBER_TYPE, HeapNumber::kSize); | 70 CheckMap(heap->heap_number_map(), HEAP_NUMBER_TYPE, HeapNumber::kSize); |
71 #define SIMD128_TYPE(TYPE, Type, type, lane_count, lane_type) \ | 71 #define SIMD128_TYPE(TYPE, Type, type, lane_count, lane_type) \ |
72 CheckMap(heap->type##_map(), SIMD128_VALUE_TYPE, Type::kSize); | 72 CheckMap(heap->type##_map(), SIMD128_VALUE_TYPE, Type::kSize); |
73 SIMD128_TYPES(SIMD128_TYPE) | 73 SIMD128_TYPES(SIMD128_TYPE) |
74 #undef SIMD128_TYPE | 74 #undef SIMD128_TYPE |
75 CheckMap(heap->fixed_array_map(), FIXED_ARRAY_TYPE, kVariableSizeSentinel); | 75 CheckMap(heap->fixed_array_map(), FIXED_ARRAY_TYPE, kVariableSizeSentinel); |
76 CheckMap(heap->string_map(), STRING_TYPE, kVariableSizeSentinel); | 76 CheckMap(heap->string_map(), STRING_TYPE, kVariableSizeSentinel); |
77 } | 77 } |
78 | 78 |
| 79 static void VerifyStoredPrototypeMap(Isolate* isolate, |
| 80 int stored_map_context_index, |
| 81 int stored_ctor_context_index) { |
| 82 Handle<Context> context = isolate->native_context(); |
| 83 |
| 84 Handle<Map> this_map(Map::cast(context->get(stored_map_context_index))); |
| 85 |
| 86 Handle<JSFunction> fun( |
| 87 JSFunction::cast(context->get(stored_ctor_context_index))); |
| 88 Handle<JSObject> proto(JSObject::cast(fun->initial_map()->prototype())); |
| 89 Handle<Map> that_map(proto->map()); |
| 90 |
| 91 CHECK(proto->HasFastProperties()); |
| 92 CHECK_EQ(*this_map, *that_map); |
| 93 } |
| 94 |
| 95 // Checks that critical maps stored on the context (mostly used for fast-path |
| 96 // checks) are unchanged after initialization. |
| 97 TEST(ContextMaps) { |
| 98 CcTest::InitializeVM(); |
| 99 Isolate* isolate = CcTest::i_isolate(); |
| 100 HandleScope handle_scope(isolate); |
| 101 |
| 102 VerifyStoredPrototypeMap(isolate, |
| 103 Context::STRING_FUNCTION_PROTOTYPE_MAP_INDEX, |
| 104 Context::STRING_FUNCTION_INDEX); |
| 105 VerifyStoredPrototypeMap(isolate, Context::REGEXP_PROTOTYPE_MAP_INDEX, |
| 106 Context::REGEXP_FUNCTION_INDEX); |
| 107 VerifyStoredPrototypeMap(isolate, Context::PROMISE_PROTOTYPE_MAP_INDEX, |
| 108 Context::PROMISE_FUNCTION_INDEX); |
| 109 } |
79 | 110 |
80 static void CheckOddball(Isolate* isolate, Object* obj, const char* string) { | 111 static void CheckOddball(Isolate* isolate, Object* obj, const char* string) { |
81 CHECK(obj->IsOddball()); | 112 CHECK(obj->IsOddball()); |
82 Handle<Object> handle(obj, isolate); | 113 Handle<Object> handle(obj, isolate); |
83 Object* print_string = *Object::ToString(isolate, handle).ToHandleChecked(); | 114 Object* print_string = *Object::ToString(isolate, handle).ToHandleChecked(); |
84 CHECK(String::cast(print_string)->IsUtf8EqualTo(CStrVector(string))); | 115 CHECK(String::cast(print_string)->IsUtf8EqualTo(CStrVector(string))); |
85 } | 116 } |
86 | 117 |
87 | 118 |
88 static void CheckSmi(Isolate* isolate, int value, const char* string) { | 119 static void CheckSmi(Isolate* isolate, int value, const char* string) { |
(...skipping 7001 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7090 CHECK(!heap->code_space()->FirstPage()->Contains(code->address())); | 7121 CHECK(!heap->code_space()->FirstPage()->Contains(code->address())); |
7091 | 7122 |
7092 // Ensure it's not in large object space. | 7123 // Ensure it's not in large object space. |
7093 MemoryChunk* chunk = MemoryChunk::FromAddress(code->address()); | 7124 MemoryChunk* chunk = MemoryChunk::FromAddress(code->address()); |
7094 CHECK(chunk->owner()->identity() != LO_SPACE); | 7125 CHECK(chunk->owner()->identity() != LO_SPACE); |
7095 CHECK(chunk->NeverEvacuate()); | 7126 CHECK(chunk->NeverEvacuate()); |
7096 } | 7127 } |
7097 | 7128 |
7098 } // namespace internal | 7129 } // namespace internal |
7099 } // namespace v8 | 7130 } // namespace v8 |
OLD | NEW |