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

Side by Side Diff: src/objects.cc

Issue 240813002: Track up to 5 stable maps as field type. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 8 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
« no previous file with comments | « src/ia32/stub-cache-ia32.cc ('k') | src/objects-debug.cc » ('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 // 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 #ifdef ENABLE_DISASSEMBLER 56 #ifdef ENABLE_DISASSEMBLER
57 #include "disasm.h" 57 #include "disasm.h"
58 #include "disassembler.h" 58 #include "disassembler.h"
59 #endif 59 #endif
60 60
61 namespace v8 { 61 namespace v8 {
62 namespace internal { 62 namespace internal {
63 63
64 Handle<HeapType> Object::OptimalType(Isolate* isolate, 64 Handle<HeapType> Object::OptimalType(Isolate* isolate,
65 Representation representation) { 65 Representation representation) {
66 if (!FLAG_track_field_types) return HeapType::Any(isolate); 66 if (FLAG_track_field_types) {
67 if (representation.IsNone()) return HeapType::None(isolate); 67 if (representation.IsNone()) return HeapType::None(isolate);
68 if (representation.IsHeapObject() && IsHeapObject()) { 68 if (representation.IsHeapObject() && IsHeapObject()) {
69 // We can track only JavaScript objects with stable maps. 69 // We can track only JavaScript objects with stable maps.
70 Handle<Map> map(HeapObject::cast(this)->map(), isolate); 70 Handle<Map> map(HeapObject::cast(this)->map(), isolate);
71 if (map->is_stable() && 71 if (map->is_stable() &&
72 map->instance_type() >= FIRST_NONCALLABLE_SPEC_OBJECT_TYPE && 72 map->instance_type() >= FIRST_NONCALLABLE_SPEC_OBJECT_TYPE &&
73 map->instance_type() <= LAST_NONCALLABLE_SPEC_OBJECT_TYPE) { 73 map->instance_type() <= LAST_NONCALLABLE_SPEC_OBJECT_TYPE) {
74 return HeapType::Class(map, isolate); 74 return HeapType::Class(map, isolate);
75 }
75 } 76 }
76 } 77 }
77 return HeapType::Any(isolate); 78 return HeapType::Any(isolate);
78 } 79 }
79 80
80 81
81 MaybeHandle<JSReceiver> Object::ToObject(Isolate* isolate, 82 MaybeHandle<JSReceiver> Object::ToObject(Isolate* isolate,
82 Handle<Object> object, 83 Handle<Object> object,
83 Handle<Context> native_context) { 84 Handle<Context> native_context) {
84 if (object->IsJSReceiver()) return Handle<JSReceiver>::cast(object); 85 if (object->IsJSReceiver()) return Handle<JSReceiver>::cast(object);
(...skipping 2439 matching lines...) Expand 10 before | Expand all | Expand 10 after
2524 instance_descriptors()->Replace(descriptor_number, desc);; 2525 instance_descriptors()->Replace(descriptor_number, desc);;
2525 } 2526 }
2526 2527
2527 2528
2528 // static 2529 // static
2529 Handle<HeapType> Map::GeneralizeFieldType(Handle<HeapType> old_field_type, 2530 Handle<HeapType> Map::GeneralizeFieldType(Handle<HeapType> old_field_type,
2530 Handle<HeapType> new_field_type, 2531 Handle<HeapType> new_field_type,
2531 Isolate* isolate) { 2532 Isolate* isolate) {
2532 if (new_field_type->NowIs(old_field_type)) return old_field_type; 2533 if (new_field_type->NowIs(old_field_type)) return old_field_type;
2533 if (old_field_type->NowIs(new_field_type)) return new_field_type; 2534 if (old_field_type->NowIs(new_field_type)) return new_field_type;
2535 int num_old_classes = old_field_type->NumClasses();
2536 int num_new_classes = new_field_type->NumClasses();
2537 if (num_old_classes > 0 &&
2538 num_new_classes > 0 &&
2539 num_old_classes + num_new_classes <= 5 &&
Sven Panne 2014/04/17 06:43:41 Perhaps give the "5" a name...
Benedikt Meurer 2014/04/17 07:26:35 Done.
2540 old_field_type->NowStable() && new_field_type->NowStable()) {
2541 return HeapType::Union(new_field_type, old_field_type, isolate);
Sven Panne 2014/04/17 06:43:41 As discussed offline: Perhaps calculate the union
Benedikt Meurer 2014/04/17 07:26:35 Done.
2542 }
2534 return HeapType::Any(isolate); 2543 return HeapType::Any(isolate);
2535 } 2544 }
2536 2545
2537 2546
2538 // static 2547 // static
2539 void Map::GeneralizeFieldType(Handle<Map> map, 2548 void Map::GeneralizeFieldType(Handle<Map> map,
2540 int modify_index, 2549 int modify_index,
2541 Handle<HeapType> new_field_type) { 2550 Handle<HeapType> new_field_type) {
2542 Isolate* isolate = map->GetIsolate(); 2551 Isolate* isolate = map->GetIsolate();
2543 Handle<Map> field_owner(map->FindFieldOwner(modify_index), isolate); 2552 Handle<Map> field_owner(map->FindFieldOwner(modify_index), isolate);
(...skipping 14567 matching lines...) Expand 10 before | Expand all | Expand 10 after
17111 #define ERROR_MESSAGES_TEXTS(C, T) T, 17120 #define ERROR_MESSAGES_TEXTS(C, T) T,
17112 static const char* error_messages_[] = { 17121 static const char* error_messages_[] = {
17113 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) 17122 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)
17114 }; 17123 };
17115 #undef ERROR_MESSAGES_TEXTS 17124 #undef ERROR_MESSAGES_TEXTS
17116 return error_messages_[reason]; 17125 return error_messages_[reason];
17117 } 17126 }
17118 17127
17119 17128
17120 } } // namespace v8::internal 17129 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ia32/stub-cache-ia32.cc ('k') | src/objects-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698