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

Side by Side Diff: src/compiler/access-info.cc

Issue 1453653003: [turbofan] Add support for special JSArrayBufferView accessors. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 1 month 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
« no previous file with comments | « src/compiler/access-info.h ('k') | src/compiler/js-native-context-specialization.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 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 <ostream> 5 #include <ostream>
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/compilation-dependencies.h" 8 #include "src/compilation-dependencies.h"
9 #include "src/compiler/access-info.h" 9 #include "src/compiler/access-info.h"
10 #include "src/field-index-inl.h" 10 #include "src/field-index-inl.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 PropertyAccessInfo PropertyAccessInfo::DataConstant( 68 PropertyAccessInfo PropertyAccessInfo::DataConstant(
69 Type* receiver_type, Handle<Object> constant, 69 Type* receiver_type, Handle<Object> constant,
70 MaybeHandle<JSObject> holder) { 70 MaybeHandle<JSObject> holder) {
71 return PropertyAccessInfo(holder, constant, receiver_type); 71 return PropertyAccessInfo(holder, constant, receiver_type);
72 } 72 }
73 73
74 74
75 // static 75 // static
76 PropertyAccessInfo PropertyAccessInfo::DataField( 76 PropertyAccessInfo PropertyAccessInfo::DataField(
77 Type* receiver_type, FieldIndex field_index, Type* field_type, 77 Type* receiver_type, FieldIndex field_index, Type* field_type,
78 MaybeHandle<JSObject> holder, MaybeHandle<Map> transition_map) { 78 FieldCheck field_check, MaybeHandle<JSObject> holder,
79 return PropertyAccessInfo(holder, transition_map, field_index, field_type, 79 MaybeHandle<Map> transition_map) {
80 receiver_type); 80 return PropertyAccessInfo(holder, transition_map, field_index, field_check,
81 field_type, receiver_type);
81 } 82 }
82 83
83 84
84 ElementAccessInfo::ElementAccessInfo() : receiver_type_(Type::None()) {} 85 ElementAccessInfo::ElementAccessInfo() : receiver_type_(Type::None()) {}
85 86
86 87
87 ElementAccessInfo::ElementAccessInfo(Type* receiver_type, 88 ElementAccessInfo::ElementAccessInfo(Type* receiver_type,
88 ElementsKind elements_kind, 89 ElementsKind elements_kind,
89 MaybeHandle<JSObject> holder) 90 MaybeHandle<JSObject> holder)
90 : elements_kind_(elements_kind), 91 : elements_kind_(elements_kind),
(...skipping 18 matching lines...) Expand all
109 Type* receiver_type) 110 Type* receiver_type)
110 : kind_(kDataConstant), 111 : kind_(kDataConstant),
111 receiver_type_(receiver_type), 112 receiver_type_(receiver_type),
112 constant_(constant), 113 constant_(constant),
113 holder_(holder), 114 holder_(holder),
114 field_type_(Type::Any()) {} 115 field_type_(Type::Any()) {}
115 116
116 117
117 PropertyAccessInfo::PropertyAccessInfo(MaybeHandle<JSObject> holder, 118 PropertyAccessInfo::PropertyAccessInfo(MaybeHandle<JSObject> holder,
118 MaybeHandle<Map> transition_map, 119 MaybeHandle<Map> transition_map,
119 FieldIndex field_index, Type* field_type, 120 FieldIndex field_index,
121 FieldCheck field_check, Type* field_type,
120 Type* receiver_type) 122 Type* receiver_type)
121 : kind_(kDataField), 123 : kind_(kDataField),
122 receiver_type_(receiver_type), 124 receiver_type_(receiver_type),
123 transition_map_(transition_map), 125 transition_map_(transition_map),
124 holder_(holder), 126 holder_(holder),
125 field_index_(field_index), 127 field_index_(field_index),
128 field_check_(field_check),
126 field_type_(field_type) {} 129 field_type_(field_type) {}
127 130
128 131
129 AccessInfoFactory::AccessInfoFactory(CompilationDependencies* dependencies, 132 AccessInfoFactory::AccessInfoFactory(CompilationDependencies* dependencies,
130 Handle<Context> native_context, Zone* zone) 133 Handle<Context> native_context, Zone* zone)
131 : dependencies_(dependencies), 134 : dependencies_(dependencies),
132 native_context_(native_context), 135 native_context_(native_context),
133 isolate_(native_context->GetIsolate()), 136 isolate_(native_context->GetIsolate()),
134 type_cache_(TypeCache::Get()), 137 type_cache_(TypeCache::Get()),
135 zone_(zone) {} 138 zone_(zone) {}
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 // runtime/GC interaction. 282 // runtime/GC interaction.
280 field_type = Type::TaggedPointer(); 283 field_type = Type::TaggedPointer();
281 } else if (!Type::Any()->Is(field_type)) { 284 } else if (!Type::Any()->Is(field_type)) {
282 // Add proper code dependencies in case of stable field map(s). 285 // Add proper code dependencies in case of stable field map(s).
283 Handle<Map> field_owner_map(map->FindFieldOwner(number), isolate()); 286 Handle<Map> field_owner_map(map->FindFieldOwner(number), isolate());
284 dependencies()->AssumeFieldType(field_owner_map); 287 dependencies()->AssumeFieldType(field_owner_map);
285 } 288 }
286 DCHECK(field_type->Is(Type::TaggedPointer())); 289 DCHECK(field_type->Is(Type::TaggedPointer()));
287 } 290 }
288 *access_info = PropertyAccessInfo::DataField( 291 *access_info = PropertyAccessInfo::DataField(
289 Type::Class(receiver_map, zone()), field_index, field_type, holder); 292 Type::Class(receiver_map, zone()), field_index, field_type,
293 FieldCheck::kNone, holder);
290 return true; 294 return true;
291 } else { 295 } else {
292 // TODO(bmeurer): Add support for accessors. 296 // TODO(bmeurer): Add support for accessors.
293 return false; 297 return false;
294 } 298 }
295 } 299 }
296 300
297 // Don't search on the prototype chain for special indices in case of 301 // Don't search on the prototype chain for special indices in case of
298 // integer indexed exotic objects (see ES6 section 9.4.5). 302 // integer indexed exotic objects (see ES6 section 9.4.5).
299 if (map->IsJSTypedArrayMap() && name->IsString() && 303 if (map->IsJSTypedArrayMap() && name->IsString() &&
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 } else if (IsFastElementsKind(map->elements_kind())) { 387 } else if (IsFastElementsKind(map->elements_kind())) {
384 field_type = type_cache_.kFixedArrayLengthType; 388 field_type = type_cache_.kFixedArrayLengthType;
385 } else { 389 } else {
386 field_type = type_cache_.kJSArrayLengthType; 390 field_type = type_cache_.kJSArrayLengthType;
387 } 391 }
388 } 392 }
389 *access_info = PropertyAccessInfo::DataField(Type::Class(map, zone()), 393 *access_info = PropertyAccessInfo::DataField(Type::Class(map, zone()),
390 field_index, field_type); 394 field_index, field_type);
391 return true; 395 return true;
392 } 396 }
397 // Check for special JSArrayBufferView field accessors.
398 if (Accessors::IsJSArrayBufferViewFieldAccessor(map, name, &offset)) {
399 FieldIndex field_index = FieldIndex::ForInObjectOffset(offset);
400 Type* field_type = Type::Tagged();
401 if (Name::Equals(factory()->byte_length_string(), name) ||
402 Name::Equals(factory()->byte_offset_string(), name)) {
403 // The JSArrayBufferView::byte_length and JSArrayBufferView::byte_offset
404 // properties are always numbers in the range [0, kMaxSafeInteger].
405 field_type = type_cache_.kPositiveSafeInteger;
406 } else if (map->IsJSTypedArrayMap()) {
407 DCHECK(Name::Equals(factory()->length_string(), name));
408 // The JSTypedArray::length property is always a number in the range
409 // [0, kMaxSafeInteger].
410 field_type = type_cache_.kPositiveSafeInteger;
411 }
412 *access_info = PropertyAccessInfo::DataField(
413 Type::Class(map, zone()), field_index, field_type,
414 FieldCheck::kJSArrayBufferViewBufferNotNeutered);
415 return true;
416 }
393 return false; 417 return false;
394 } 418 }
395 419
396 420
397 bool AccessInfoFactory::LookupTransition(Handle<Map> map, Handle<Name> name, 421 bool AccessInfoFactory::LookupTransition(Handle<Map> map, Handle<Name> name,
398 MaybeHandle<JSObject> holder, 422 MaybeHandle<JSObject> holder,
399 PropertyAccessInfo* access_info) { 423 PropertyAccessInfo* access_info) {
400 // Check if the {map} has a data transition with the given {name}. 424 // Check if the {map} has a data transition with the given {name}.
401 if (map->unused_property_fields() == 0) return false; 425 if (map->unused_property_fields() == 0) return false;
402 Handle<Map> transition_map; 426 Handle<Map> transition_map;
(...skipping 30 matching lines...) Expand all
433 return false; 457 return false;
434 } else if (!Type::Any()->Is(field_type)) { 458 } else if (!Type::Any()->Is(field_type)) {
435 // Add proper code dependencies in case of stable field map(s). 459 // Add proper code dependencies in case of stable field map(s).
436 Handle<Map> field_owner_map(transition_map->FindFieldOwner(number), 460 Handle<Map> field_owner_map(transition_map->FindFieldOwner(number),
437 isolate()); 461 isolate());
438 dependencies()->AssumeFieldType(field_owner_map); 462 dependencies()->AssumeFieldType(field_owner_map);
439 } 463 }
440 DCHECK(field_type->Is(Type::TaggedPointer())); 464 DCHECK(field_type->Is(Type::TaggedPointer()));
441 } 465 }
442 dependencies()->AssumeMapNotDeprecated(transition_map); 466 dependencies()->AssumeMapNotDeprecated(transition_map);
443 *access_info = 467 *access_info = PropertyAccessInfo::DataField(
444 PropertyAccessInfo::DataField(Type::Class(map, zone()), field_index, 468 Type::Class(map, zone()), field_index, field_type, FieldCheck::kNone,
445 field_type, holder, transition_map); 469 holder, transition_map);
446 return true; 470 return true;
447 } 471 }
448 return false; 472 return false;
449 } 473 }
450 474
451 475
452 Factory* AccessInfoFactory::factory() const { return isolate()->factory(); } 476 Factory* AccessInfoFactory::factory() const { return isolate()->factory(); }
453 477
454 } // namespace compiler 478 } // namespace compiler
455 } // namespace internal 479 } // namespace internal
456 } // namespace v8 480 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/access-info.h ('k') | src/compiler/js-native-context-specialization.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698