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

Side by Side Diff: src/objects.cc

Issue 169113005: Revert "Handlify DescriptorArray::Merge()." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 10 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/objects.h ('k') | no next file » | 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 7974 matching lines...) Expand 10 before | Expand all | Expand 10 after
7985 DescriptorArray* src, 7985 DescriptorArray* src,
7986 int src_index, 7986 int src_index,
7987 const WhitenessWitness& witness) { 7987 const WhitenessWitness& witness) {
7988 Object* value = src->GetValue(src_index); 7988 Object* value = src->GetValue(src_index);
7989 PropertyDetails details = src->GetDetails(src_index); 7989 PropertyDetails details = src->GetDetails(src_index);
7990 Descriptor desc(src->GetKey(src_index), value, details); 7990 Descriptor desc(src->GetKey(src_index), value, details);
7991 Set(dst_index, &desc, witness); 7991 Set(dst_index, &desc, witness);
7992 } 7992 }
7993 7993
7994 7994
7995 // Generalize the |other| descriptor array by merging it into the (at least
7996 // partly) updated |desc| descriptor array.
7997 // The method merges two descriptor array in three parts. Both descriptor arrays
7998 // are identical up to |verbatim|. They also overlap in keys up to |valid|.
7999 // Between |verbatim| and |valid|, the resulting descriptor type as well as the
8000 // representation are generalized from both |desc| and |other|. Beyond |valid|,
8001 // the descriptors are copied verbatim from |other| up to |new_size|.
8002 // In case of incompatible types, the type and representation of |other| is
8003 // used.
8004 Handle<DescriptorArray> DescriptorArray::Merge(Handle<DescriptorArray> desc, 7995 Handle<DescriptorArray> DescriptorArray::Merge(Handle<DescriptorArray> desc,
8005 int verbatim, 7996 int verbatim,
8006 int valid, 7997 int valid,
8007 int new_size, 7998 int new_size,
8008 int modify_index, 7999 int modify_index,
8009 StoreMode store_mode, 8000 StoreMode store_mode,
8010 Handle<DescriptorArray> other) { 8001 Handle<DescriptorArray> other) {
8002 CALL_HEAP_FUNCTION(desc->GetIsolate(),
8003 desc->Merge(verbatim, valid, new_size, modify_index,
8004 store_mode, *other),
8005 DescriptorArray);
8006 }
8007
8008
8009 // Generalize the |other| descriptor array by merging it into the (at least
8010 // partly) updated |this| descriptor array.
8011 // The method merges two descriptor array in three parts. Both descriptor arrays
8012 // are identical up to |verbatim|. They also overlap in keys up to |valid|.
8013 // Between |verbatim| and |valid|, the resulting descriptor type as well as the
8014 // representation are generalized from both |this| and |other|. Beyond |valid|,
8015 // the descriptors are copied verbatim from |other| up to |new_size|.
8016 // In case of incompatible types, the type and representation of |other| is
8017 // used.
8018 MaybeObject* DescriptorArray::Merge(int verbatim,
8019 int valid,
8020 int new_size,
8021 int modify_index,
8022 StoreMode store_mode,
8023 DescriptorArray* other) {
8011 ASSERT(verbatim <= valid); 8024 ASSERT(verbatim <= valid);
8012 ASSERT(valid <= new_size); 8025 ASSERT(valid <= new_size);
8013 8026
8027 DescriptorArray* result;
8014 // Allocate a new descriptor array large enough to hold the required 8028 // Allocate a new descriptor array large enough to hold the required
8015 // descriptors, with minimally the exact same size as this descriptor array. 8029 // descriptors, with minimally the exact same size as this descriptor array.
8016 Isolate* isolate = desc->GetIsolate(); 8030 MaybeObject* maybe_descriptors = DescriptorArray::Allocate(
8017 Handle<DescriptorArray> result = isolate->factory()->NewDescriptorArray( 8031 GetIsolate(), new_size,
8018 new_size, Max(new_size, other->number_of_descriptors()) - new_size); 8032 Max(new_size, other->number_of_descriptors()) - new_size);
8019 ASSERT(result->length() > desc->length() || 8033 if (!maybe_descriptors->To(&result)) return maybe_descriptors;
8034 ASSERT(result->length() > length() ||
8020 result->NumberOfSlackDescriptors() > 0 || 8035 result->NumberOfSlackDescriptors() > 0 ||
8021 result->number_of_descriptors() == other->number_of_descriptors()); 8036 result->number_of_descriptors() == other->number_of_descriptors());
8022 ASSERT(result->number_of_descriptors() == new_size); 8037 ASSERT(result->number_of_descriptors() == new_size);
8023 8038
8039 DescriptorArray::WhitenessWitness witness(result);
8040
8024 int descriptor; 8041 int descriptor;
8025 8042
8026 // 0 -> |verbatim| 8043 // 0 -> |verbatim|
8027 int current_offset = 0; 8044 int current_offset = 0;
8028 for (descriptor = 0; descriptor < verbatim; descriptor++) { 8045 for (descriptor = 0; descriptor < verbatim; descriptor++) {
8029 if (desc->GetDetails(descriptor).type() == FIELD) current_offset++; 8046 if (GetDetails(descriptor).type() == FIELD) current_offset++;
8030 Descriptor d(other->GetKey(descriptor), 8047 result->CopyFrom(descriptor, other, descriptor, witness);
8031 other->GetValue(descriptor),
8032 other->GetDetails(descriptor));
8033 result->Set(descriptor, &d);
8034 } 8048 }
8035 8049
8036 // |verbatim| -> |valid| 8050 // |verbatim| -> |valid|
8037 for (; descriptor < valid; descriptor++) { 8051 for (; descriptor < valid; descriptor++) {
8038 PropertyDetails details = desc->GetDetails(descriptor); 8052 Name* key = GetKey(descriptor);
8053 PropertyDetails details = GetDetails(descriptor);
8039 PropertyDetails other_details = other->GetDetails(descriptor); 8054 PropertyDetails other_details = other->GetDetails(descriptor);
8040 8055
8041 if (details.type() == FIELD || other_details.type() == FIELD || 8056 if (details.type() == FIELD || other_details.type() == FIELD ||
8042 (store_mode == FORCE_FIELD && descriptor == modify_index) || 8057 (store_mode == FORCE_FIELD && descriptor == modify_index) ||
8043 (details.type() == CONSTANT && 8058 (details.type() == CONSTANT &&
8044 other_details.type() == CONSTANT && 8059 other_details.type() == CONSTANT &&
8045 desc->GetValue(descriptor) != other->GetValue(descriptor))) { 8060 GetValue(descriptor) != other->GetValue(descriptor))) {
8046 Representation representation = 8061 Representation representation =
8047 details.representation().generalize(other_details.representation()); 8062 details.representation().generalize(other_details.representation());
8048 FieldDescriptor d(desc->GetKey(descriptor), 8063 FieldDescriptor d(key,
8049 current_offset++, 8064 current_offset++,
8050 other_details.attributes(), 8065 other_details.attributes(),
8051 representation); 8066 representation);
8052 result->Set(descriptor, &d); 8067 result->Set(descriptor, &d, witness);
8053 } else { 8068 } else {
8054 Descriptor d(other->GetKey(descriptor), 8069 result->CopyFrom(descriptor, other, descriptor, witness);
8055 other->GetValue(descriptor),
8056 other->GetDetails(descriptor));
8057 result->Set(descriptor, &d);
8058 } 8070 }
8059 } 8071 }
8060 8072
8061 // |valid| -> |new_size| 8073 // |valid| -> |new_size|
8062 for (; descriptor < new_size; descriptor++) { 8074 for (; descriptor < new_size; descriptor++) {
8063 PropertyDetails details = other->GetDetails(descriptor); 8075 PropertyDetails details = other->GetDetails(descriptor);
8064
8065 if (details.type() == FIELD || 8076 if (details.type() == FIELD ||
8066 (store_mode == FORCE_FIELD && descriptor == modify_index)) { 8077 (store_mode == FORCE_FIELD && descriptor == modify_index)) {
8067 FieldDescriptor d(other->GetKey(descriptor), 8078 Name* key = other->GetKey(descriptor);
8079 FieldDescriptor d(key,
8068 current_offset++, 8080 current_offset++,
8069 details.attributes(), 8081 details.attributes(),
8070 details.representation()); 8082 details.representation());
8071 result->Set(descriptor, &d); 8083 result->Set(descriptor, &d, witness);
8072 } else { 8084 } else {
8073 Descriptor d(other->GetKey(descriptor), 8085 result->CopyFrom(descriptor, other, descriptor, witness);
8074 other->GetValue(descriptor),
8075 other->GetDetails(descriptor));
8076 result->Set(descriptor, &d);
8077 } 8086 }
8078 } 8087 }
8079 8088
8080 result->Sort(); 8089 result->Sort();
8081 return result; 8090 return result;
8082 } 8091 }
8083 8092
8084 8093
8085 // Checks whether a merge of |other| into |this| would return a copy of |this|. 8094 // Checks whether a merge of |other| into |this| would return a copy of |this|.
8086 bool DescriptorArray::IsMoreGeneralThan(int verbatim, 8095 bool DescriptorArray::IsMoreGeneralThan(int verbatim,
(...skipping 8400 matching lines...) Expand 10 before | Expand all | Expand 10 after
16487 #define ERROR_MESSAGES_TEXTS(C, T) T, 16496 #define ERROR_MESSAGES_TEXTS(C, T) T,
16488 static const char* error_messages_[] = { 16497 static const char* error_messages_[] = {
16489 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) 16498 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)
16490 }; 16499 };
16491 #undef ERROR_MESSAGES_TEXTS 16500 #undef ERROR_MESSAGES_TEXTS
16492 return error_messages_[reason]; 16501 return error_messages_[reason];
16493 } 16502 }
16494 16503
16495 16504
16496 } } // namespace v8::internal 16505 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698