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

Side by Side Diff: src/objects.cc

Issue 2741683004: [rename] Rename internal field to embedder field. (Closed)
Patch Set: DEPRECATE_SOON(GetInternalField) Created 3 years, 9 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
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/objects.h" 5 #include "src/objects.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <iomanip> 8 #include <iomanip>
9 #include <memory> 9 #include <memory>
10 #include <sstream> 10 #include <sstream>
(...skipping 11886 matching lines...) Expand 10 before | Expand all | Expand 10 after
11897 return true; 11897 return true;
11898 } 11898 }
11899 11899
11900 11900
11901 bool Map::EquivalentToForNormalization(Map* other, 11901 bool Map::EquivalentToForNormalization(Map* other,
11902 PropertyNormalizationMode mode) { 11902 PropertyNormalizationMode mode) {
11903 int properties = 11903 int properties =
11904 mode == CLEAR_INOBJECT_PROPERTIES ? 0 : other->GetInObjectProperties(); 11904 mode == CLEAR_INOBJECT_PROPERTIES ? 0 : other->GetInObjectProperties();
11905 return CheckEquivalent(this, other) && bit_field2() == other->bit_field2() && 11905 return CheckEquivalent(this, other) && bit_field2() == other->bit_field2() &&
11906 GetInObjectProperties() == properties && 11906 GetInObjectProperties() == properties &&
11907 JSObject::GetInternalFieldCount(this) == 11907 JSObject::GetEmbedderFieldCount(this) ==
11908 JSObject::GetInternalFieldCount(other); 11908 JSObject::GetEmbedderFieldCount(other);
11909 } 11909 }
11910 11910
11911 11911
11912 bool JSFunction::Inlines(SharedFunctionInfo* candidate) { 11912 bool JSFunction::Inlines(SharedFunctionInfo* candidate) {
11913 DisallowHeapAllocation no_gc; 11913 DisallowHeapAllocation no_gc;
11914 if (shared() == candidate) return true; 11914 if (shared() == candidate) return true;
11915 if (code()->kind() != Code::OPTIMIZED_FUNCTION) return false; 11915 if (code()->kind() != Code::OPTIMIZED_FUNCTION) return false;
11916 DeoptimizationInputData* const data = 11916 DeoptimizationInputData* const data =
11917 DeoptimizationInputData::cast(code()->deoptimization_data()); 11917 DeoptimizationInputData::cast(code()->deoptimization_data());
11918 if (data->length() == 0) return false; 11918 if (data->length() == 0) return false;
(...skipping 852 matching lines...) Expand 10 before | Expand all | Expand 10 after
12771 12771
12772 // Create a new map with the size and number of in-object properties 12772 // Create a new map with the size and number of in-object properties
12773 // suggested by |function|. 12773 // suggested by |function|.
12774 12774
12775 // Link initial map and constructor function if the new.target is actually a 12775 // Link initial map and constructor function if the new.target is actually a
12776 // subclass constructor. 12776 // subclass constructor.
12777 if (IsDerivedConstructor(function->shared()->kind())) { 12777 if (IsDerivedConstructor(function->shared()->kind())) {
12778 Handle<Object> prototype(function->instance_prototype(), isolate); 12778 Handle<Object> prototype(function->instance_prototype(), isolate);
12779 InstanceType instance_type = constructor_initial_map->instance_type(); 12779 InstanceType instance_type = constructor_initial_map->instance_type();
12780 DCHECK(CanSubclassHaveInobjectProperties(instance_type)); 12780 DCHECK(CanSubclassHaveInobjectProperties(instance_type));
12781 int internal_fields = 12781 int embedder_fields =
12782 JSObject::GetInternalFieldCount(*constructor_initial_map); 12782 JSObject::GetEmbedderFieldCount(*constructor_initial_map);
12783 int pre_allocated = constructor_initial_map->GetInObjectProperties() - 12783 int pre_allocated = constructor_initial_map->GetInObjectProperties() -
12784 constructor_initial_map->unused_property_fields(); 12784 constructor_initial_map->unused_property_fields();
12785 int instance_size; 12785 int instance_size;
12786 int in_object_properties; 12786 int in_object_properties;
12787 function->CalculateInstanceSizeForDerivedClass( 12787 function->CalculateInstanceSizeForDerivedClass(
12788 instance_type, internal_fields, &instance_size, 12788 instance_type, embedder_fields, &instance_size,
12789 &in_object_properties); 12789 &in_object_properties);
12790 12790
12791 int unused_property_fields = in_object_properties - pre_allocated; 12791 int unused_property_fields = in_object_properties - pre_allocated;
12792 Handle<Map> map = 12792 Handle<Map> map =
12793 Map::CopyInitialMap(constructor_initial_map, instance_size, 12793 Map::CopyInitialMap(constructor_initial_map, instance_size,
12794 in_object_properties, unused_property_fields); 12794 in_object_properties, unused_property_fields);
12795 map->set_new_target_is_base(false); 12795 map->set_new_target_is_base(false);
12796 12796
12797 JSFunction::SetInitialMap(function, map, prototype); 12797 JSFunction::SetInitialMap(function, map, prototype);
12798 map->SetConstructor(*constructor); 12798 map->SetConstructor(*constructor);
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after
13435 if (!script()->IsScript()) return false; 13435 if (!script()->IsScript()) return false;
13436 return !optimization_disabled(); 13436 return !optimization_disabled();
13437 } 13437 }
13438 13438
13439 13439
13440 int SharedFunctionInfo::SourceSize() { 13440 int SharedFunctionInfo::SourceSize() {
13441 return end_position() - start_position(); 13441 return end_position() - start_position();
13442 } 13442 }
13443 13443
13444 void JSFunction::CalculateInstanceSizeHelper(InstanceType instance_type, 13444 void JSFunction::CalculateInstanceSizeHelper(InstanceType instance_type,
13445 int requested_internal_fields, 13445 int requested_embedder_fields,
13446 int requested_in_object_properties, 13446 int requested_in_object_properties,
13447 int* instance_size, 13447 int* instance_size,
13448 int* in_object_properties) { 13448 int* in_object_properties) {
13449 int header_size = JSObject::GetHeaderSize(instance_type); 13449 int header_size = JSObject::GetHeaderSize(instance_type);
13450 DCHECK_LE(requested_internal_fields, 13450 DCHECK_LE(requested_embedder_fields,
13451 (JSObject::kMaxInstanceSize - header_size) >> kPointerSizeLog2); 13451 (JSObject::kMaxInstanceSize - header_size) >> kPointerSizeLog2);
13452 *instance_size = 13452 *instance_size =
13453 Min(header_size + 13453 Min(header_size +
13454 ((requested_internal_fields + requested_in_object_properties) 13454 ((requested_embedder_fields + requested_in_object_properties)
13455 << kPointerSizeLog2), 13455 << kPointerSizeLog2),
13456 JSObject::kMaxInstanceSize); 13456 JSObject::kMaxInstanceSize);
13457 *in_object_properties = ((*instance_size - header_size) >> kPointerSizeLog2) - 13457 *in_object_properties = ((*instance_size - header_size) >> kPointerSizeLog2) -
13458 requested_internal_fields; 13458 requested_embedder_fields;
13459 } 13459 }
13460 13460
13461
13462 void JSFunction::CalculateInstanceSize(InstanceType instance_type, 13461 void JSFunction::CalculateInstanceSize(InstanceType instance_type,
13463 int requested_internal_fields, 13462 int requested_embedder_fields,
13464 int* instance_size, 13463 int* instance_size,
13465 int* in_object_properties) { 13464 int* in_object_properties) {
13466 CalculateInstanceSizeHelper(instance_type, requested_internal_fields, 13465 CalculateInstanceSizeHelper(instance_type, requested_embedder_fields,
13467 shared()->expected_nof_properties(), 13466 shared()->expected_nof_properties(),
13468 instance_size, in_object_properties); 13467 instance_size, in_object_properties);
13469 } 13468 }
13470 13469
13471
13472 void JSFunction::CalculateInstanceSizeForDerivedClass( 13470 void JSFunction::CalculateInstanceSizeForDerivedClass(
13473 InstanceType instance_type, int requested_internal_fields, 13471 InstanceType instance_type, int requested_embedder_fields,
13474 int* instance_size, int* in_object_properties) { 13472 int* instance_size, int* in_object_properties) {
13475 Isolate* isolate = GetIsolate(); 13473 Isolate* isolate = GetIsolate();
13476 int expected_nof_properties = 0; 13474 int expected_nof_properties = 0;
13477 for (PrototypeIterator iter(isolate, this, kStartAtReceiver); !iter.IsAtEnd(); 13475 for (PrototypeIterator iter(isolate, this, kStartAtReceiver); !iter.IsAtEnd();
13478 iter.Advance()) { 13476 iter.Advance()) {
13479 JSReceiver* current = iter.GetCurrent<JSReceiver>(); 13477 JSReceiver* current = iter.GetCurrent<JSReceiver>();
13480 if (!current->IsJSFunction()) break; 13478 if (!current->IsJSFunction()) break;
13481 JSFunction* func = JSFunction::cast(current); 13479 JSFunction* func = JSFunction::cast(current);
13482 SharedFunctionInfo* shared = func->shared(); 13480 SharedFunctionInfo* shared = func->shared();
13483 expected_nof_properties += shared->expected_nof_properties(); 13481 expected_nof_properties += shared->expected_nof_properties();
13484 if (!IsDerivedConstructor(shared->kind())) { 13482 if (!IsDerivedConstructor(shared->kind())) {
13485 break; 13483 break;
13486 } 13484 }
13487 } 13485 }
13488 CalculateInstanceSizeHelper(instance_type, requested_internal_fields, 13486 CalculateInstanceSizeHelper(instance_type, requested_embedder_fields,
13489 expected_nof_properties, instance_size, 13487 expected_nof_properties, instance_size,
13490 in_object_properties); 13488 in_object_properties);
13491 } 13489 }
13492 13490
13493 13491
13494 // Output the source code without any allocation in the heap. 13492 // Output the source code without any allocation in the heap.
13495 std::ostream& operator<<(std::ostream& os, const SourceCodeOf& v) { 13493 std::ostream& operator<<(std::ostream& os, const SourceCodeOf& v) {
13496 const SharedFunctionInfo* s = v.value; 13494 const SharedFunctionInfo* s = v.value;
13497 // For some native functions there is no source. 13495 // For some native functions there is no source.
13498 if (!s->HasSourceCode()) return os << "<No Source>"; 13496 if (!s->HasSourceCode()) return os << "<No Source>";
(...skipping 5780 matching lines...) Expand 10 before | Expand all | Expand 10 after
19279 Isolate* const isolate = GetIsolate(); 19277 Isolate* const isolate = GetIsolate();
19280 if (isolate->IsArrayBufferNeuteringIntact()) { 19278 if (isolate->IsArrayBufferNeuteringIntact()) {
19281 isolate->InvalidateArrayBufferNeuteringProtector(); 19279 isolate->InvalidateArrayBufferNeuteringProtector();
19282 } 19280 }
19283 } 19281 }
19284 19282
19285 19283
19286 void JSArrayBuffer::Setup(Handle<JSArrayBuffer> array_buffer, Isolate* isolate, 19284 void JSArrayBuffer::Setup(Handle<JSArrayBuffer> array_buffer, Isolate* isolate,
19287 bool is_external, void* data, size_t allocated_length, 19285 bool is_external, void* data, size_t allocated_length,
19288 SharedFlag shared) { 19286 SharedFlag shared) {
19289 DCHECK(array_buffer->GetInternalFieldCount() == 19287 DCHECK(array_buffer->GetEmbedderFieldCount() ==
19290 v8::ArrayBuffer::kInternalFieldCount); 19288 v8::ArrayBuffer::kEmbedderFieldCount);
19291 for (int i = 0; i < v8::ArrayBuffer::kInternalFieldCount; i++) { 19289 for (int i = 0; i < v8::ArrayBuffer::kEmbedderFieldCount; i++) {
19292 array_buffer->SetInternalField(i, Smi::kZero); 19290 array_buffer->SetEmbedderField(i, Smi::kZero);
19293 } 19291 }
19294 array_buffer->set_bit_field(0); 19292 array_buffer->set_bit_field(0);
19295 array_buffer->set_is_external(is_external); 19293 array_buffer->set_is_external(is_external);
19296 array_buffer->set_is_neuterable(shared == SharedFlag::kNotShared); 19294 array_buffer->set_is_neuterable(shared == SharedFlag::kNotShared);
19297 array_buffer->set_is_shared(shared == SharedFlag::kShared); 19295 array_buffer->set_is_shared(shared == SharedFlag::kShared);
19298 19296
19299 Handle<Object> byte_length = 19297 Handle<Object> byte_length =
19300 isolate->factory()->NewNumberFromSize(allocated_length); 19298 isolate->factory()->NewNumberFromSize(allocated_length);
19301 CHECK(byte_length->IsSmi() || byte_length->IsHeapNumber()); 19299 CHECK(byte_length->IsSmi() || byte_length->IsHeapNumber());
19302 array_buffer->set_byte_length(*byte_length); 19300 array_buffer->set_byte_length(*byte_length);
(...skipping 939 matching lines...) Expand 10 before | Expand all | Expand 10 after
20242 // depend on this. 20240 // depend on this.
20243 return DICTIONARY_ELEMENTS; 20241 return DICTIONARY_ELEMENTS;
20244 } 20242 }
20245 DCHECK_LE(kind, LAST_ELEMENTS_KIND); 20243 DCHECK_LE(kind, LAST_ELEMENTS_KIND);
20246 return kind; 20244 return kind;
20247 } 20245 }
20248 } 20246 }
20249 20247
20250 } // namespace internal 20248 } // namespace internal
20251 } // namespace v8 20249 } // namespace v8
OLDNEW
« include/v8-experimental.h ('K') | « src/objects.h ('k') | src/objects-body-descriptors.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698