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

Side by Side Diff: src/hydrogen.h

Issue 935033003: Move LookupResult into crankshaft as that's now the only place where it's still used (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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
« no previous file with comments | « src/globals.h ('k') | src/hydrogen.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 #ifndef V8_HYDROGEN_H_ 5 #ifndef V8_HYDROGEN_H_
6 #define V8_HYDROGEN_H_ 6 #define V8_HYDROGEN_H_
7 7
8 #include "src/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/accessors.h" 10 #include "src/accessors.h"
(...skipping 2343 matching lines...) Expand 10 before | Expand all | Expand 10 after
2354 BailoutId ast_id); 2354 BailoutId ast_id);
2355 bool TryInlineApiSetter(Handle<JSFunction> function, 2355 bool TryInlineApiSetter(Handle<JSFunction> function,
2356 Handle<Map> receiver_map, 2356 Handle<Map> receiver_map,
2357 BailoutId ast_id); 2357 BailoutId ast_id);
2358 bool TryInlineApiCall(Handle<JSFunction> function, 2358 bool TryInlineApiCall(Handle<JSFunction> function,
2359 HValue* receiver, 2359 HValue* receiver,
2360 SmallMapList* receiver_maps, 2360 SmallMapList* receiver_maps,
2361 int argc, 2361 int argc,
2362 BailoutId ast_id, 2362 BailoutId ast_id,
2363 ApiCallType call_type); 2363 ApiCallType call_type);
2364 static bool IsReadOnlyLengthDescriptor(Handle<Map> jsarray_map);
2364 static bool CanInlineArrayResizeOperation(Handle<Map> receiver_map); 2365 static bool CanInlineArrayResizeOperation(Handle<Map> receiver_map);
2365 2366
2366 // If --trace-inlining, print a line of the inlining trace. Inlining 2367 // If --trace-inlining, print a line of the inlining trace. Inlining
2367 // succeeded if the reason string is NULL and failed if there is a 2368 // succeeded if the reason string is NULL and failed if there is a
2368 // non-NULL reason string. 2369 // non-NULL reason string.
2369 void TraceInline(Handle<JSFunction> target, 2370 void TraceInline(Handle<JSFunction> target,
2370 Handle<JSFunction> caller, 2371 Handle<JSFunction> caller,
2371 const char* failure_reason); 2372 const char* failure_reason);
2372 2373
2373 void HandleGlobalVariableAssignment(Variable* var, 2374 void HandleGlobalVariableAssignment(Variable* var,
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
2422 HValue* object, HIfContinuation* continuation); 2423 HValue* object, HIfContinuation* continuation);
2423 2424
2424 Handle<JSFunction> array_function() { 2425 Handle<JSFunction> array_function() {
2425 return handle(isolate()->native_context()->array_function()); 2426 return handle(isolate()->native_context()->array_function());
2426 } 2427 }
2427 2428
2428 bool IsCallArrayInlineable(int argument_count, Handle<AllocationSite> site); 2429 bool IsCallArrayInlineable(int argument_count, Handle<AllocationSite> site);
2429 void BuildInlinedCallArray(Expression* expression, int argument_count, 2430 void BuildInlinedCallArray(Expression* expression, int argument_count,
2430 Handle<AllocationSite> site); 2431 Handle<AllocationSite> site);
2431 2432
2433 class LookupResult FINAL BASE_EMBEDDED {
2434 public:
2435 LookupResult()
2436 : lookup_type_(NOT_FOUND),
2437 details_(NONE, DATA, Representation::None()) {}
2438
2439 void LookupDescriptor(Map* map, Name* name) {
2440 DescriptorArray* descriptors = map->instance_descriptors();
2441 int number = descriptors->SearchWithCache(name, map);
2442 if (number == DescriptorArray::kNotFound) return NotFound();
2443 lookup_type_ = DESCRIPTOR_TYPE;
2444 details_ = descriptors->GetDetails(number);
2445 number_ = number;
2446 }
2447
2448 void LookupTransition(Map* map, Name* name, PropertyAttributes attributes) {
2449 int transition_index = map->SearchTransition(kData, name, attributes);
2450 if (transition_index == TransitionArray::kNotFound) return NotFound();
2451 lookup_type_ = TRANSITION_TYPE;
2452 transition_ = handle(map->GetTransition(transition_index));
2453 number_ = transition_->LastAdded();
2454 details_ = transition_->instance_descriptors()->GetDetails(number_);
2455 }
2456
2457 void NotFound() {
2458 lookup_type_ = NOT_FOUND;
2459 details_ = PropertyDetails(NONE, DATA, 0);
2460 }
2461
2462 Representation representation() const {
2463 DCHECK(IsFound());
2464 return details_.representation();
2465 }
2466
2467 // Property callbacks does not include transitions to callbacks.
2468 bool IsAccessorConstant() const {
2469 return !IsTransition() && details_.type() == ACCESSOR_CONSTANT;
2470 }
2471
2472 bool IsReadOnly() const {
2473 DCHECK(IsFound());
2474 return details_.IsReadOnly();
2475 }
2476
2477 bool IsData() const {
2478 return lookup_type_ == DESCRIPTOR_TYPE && details_.type() == DATA;
2479 }
2480
2481 bool IsDataConstant() const {
2482 return lookup_type_ == DESCRIPTOR_TYPE &&
2483 details_.type() == DATA_CONSTANT;
2484 }
2485
2486 bool IsConfigurable() const { return details_.IsConfigurable(); }
2487 bool IsFound() const { return lookup_type_ != NOT_FOUND; }
2488 bool IsTransition() const { return lookup_type_ == TRANSITION_TYPE; }
2489
2490 // Is the result is a property excluding transitions and the null
2491 // descriptor?
2492 bool IsProperty() const { return IsFound() && !IsTransition(); }
2493
2494 Handle<Map> GetTransitionTarget() const {
2495 DCHECK(IsTransition());
2496 return transition_;
2497 }
2498
2499 bool IsTransitionToData() const {
2500 return IsTransition() && details_.type() == DATA;
2501 }
2502
2503 int GetLocalFieldIndexFromMap(Map* map) const {
2504 return GetFieldIndexFromMap(map) - map->inobject_properties();
2505 }
2506
2507 Object* GetConstantFromMap(Map* map) const {
2508 DCHECK(details_.type() == DATA_CONSTANT);
2509 return GetValueFromMap(map);
2510 }
2511
2512 Object* GetValueFromMap(Map* map) const {
2513 DCHECK(lookup_type_ == DESCRIPTOR_TYPE ||
2514 lookup_type_ == TRANSITION_TYPE);
2515 DCHECK(number_ < map->NumberOfOwnDescriptors());
2516 return map->instance_descriptors()->GetValue(number_);
2517 }
2518
2519 int GetFieldIndexFromMap(Map* map) const {
2520 DCHECK(lookup_type_ == DESCRIPTOR_TYPE ||
2521 lookup_type_ == TRANSITION_TYPE);
2522 DCHECK(number_ < map->NumberOfOwnDescriptors());
2523 return map->instance_descriptors()->GetFieldIndex(number_);
2524 }
2525
2526 HeapType* GetFieldTypeFromMap(Map* map) const {
2527 DCHECK_NE(NOT_FOUND, lookup_type_);
2528 DCHECK(number_ < map->NumberOfOwnDescriptors());
2529 return map->instance_descriptors()->GetFieldType(number_);
2530 }
2531
2532 Map* GetFieldOwnerFromMap(Map* map) const {
2533 DCHECK(lookup_type_ == DESCRIPTOR_TYPE ||
2534 lookup_type_ == TRANSITION_TYPE);
2535 DCHECK(number_ < map->NumberOfOwnDescriptors());
2536 return map->FindFieldOwner(number_);
2537 }
2538
2539 private:
2540 // Where did we find the result;
2541 enum { NOT_FOUND, DESCRIPTOR_TYPE, TRANSITION_TYPE } lookup_type_;
2542
2543 Handle<Map> transition_;
2544 int number_;
2545 PropertyDetails details_;
2546 };
2547
2432 class PropertyAccessInfo { 2548 class PropertyAccessInfo {
2433 public: 2549 public:
2434 PropertyAccessInfo(HOptimizedGraphBuilder* builder, 2550 PropertyAccessInfo(HOptimizedGraphBuilder* builder,
2435 PropertyAccessType access_type, Handle<Map> map, 2551 PropertyAccessType access_type, Handle<Map> map,
2436 Handle<String> name) 2552 Handle<String> name)
2437 : lookup_(builder->isolate()), 2553 : builder_(builder),
2438 builder_(builder),
2439 access_type_(access_type), 2554 access_type_(access_type),
2440 map_(map), 2555 map_(map),
2441 name_(name), 2556 name_(name),
2442 field_type_(HType::Tagged()), 2557 field_type_(HType::Tagged()),
2443 access_(HObjectAccess::ForMap()) {} 2558 access_(HObjectAccess::ForMap()) {}
2444 2559
2445 // Checkes whether this PropertyAccessInfo can be handled as a monomorphic 2560 // Checkes whether this PropertyAccessInfo can be handled as a monomorphic
2446 // load named. It additionally fills in the fields necessary to generate the 2561 // load named. It additionally fills in the fields necessary to generate the
2447 // lookup code. 2562 // lookup code.
2448 bool CanAccessMonomorphic(); 2563 bool CanAccessMonomorphic();
(...skipping 29 matching lines...) Expand all
2478 *access = HObjectAccess::ForMapAndOffset(map_, offset); 2593 *access = HObjectAccess::ForMapAndOffset(map_, offset);
2479 } 2594 }
2480 return true; 2595 return true;
2481 } 2596 }
2482 return false; 2597 return false;
2483 } 2598 }
2484 2599
2485 bool has_holder() { return !holder_.is_null(); } 2600 bool has_holder() { return !holder_.is_null(); }
2486 bool IsLoad() const { return access_type_ == LOAD; } 2601 bool IsLoad() const { return access_type_ == LOAD; }
2487 2602
2488 Isolate* isolate() const { return lookup_.isolate(); } 2603 Isolate* isolate() const { return builder_->isolate(); }
2489 Handle<JSObject> holder() { return holder_; } 2604 Handle<JSObject> holder() { return holder_; }
2490 Handle<JSFunction> accessor() { return accessor_; } 2605 Handle<JSFunction> accessor() { return accessor_; }
2491 Handle<Object> constant() { return constant_; } 2606 Handle<Object> constant() { return constant_; }
2492 Handle<Map> transition() { return handle(lookup_.GetTransitionTarget()); } 2607 Handle<Map> transition() { return lookup_.GetTransitionTarget(); }
2493 SmallMapList* field_maps() { return &field_maps_; } 2608 SmallMapList* field_maps() { return &field_maps_; }
2494 HType field_type() const { return field_type_; } 2609 HType field_type() const { return field_type_; }
2495 HObjectAccess access() { return access_; } 2610 HObjectAccess access() { return access_; }
2496 2611
2497 bool IsFound() const { return lookup_.IsFound(); } 2612 bool IsFound() const { return lookup_.IsFound(); }
2498 bool IsProperty() const { return lookup_.IsProperty(); } 2613 bool IsProperty() const { return lookup_.IsProperty(); }
2499 bool IsData() const { return lookup_.IsData(); } 2614 bool IsData() const { return lookup_.IsData(); }
2500 bool IsDataConstant() const { return lookup_.IsDataConstant(); } 2615 bool IsDataConstant() const { return lookup_.IsDataConstant(); }
2501 bool IsAccessorConstant() const { return lookup_.IsAccessorConstant(); } 2616 bool IsAccessorConstant() const { return lookup_.IsAccessorConstant(); }
2502 bool IsTransition() const { return lookup_.IsTransition(); } 2617 bool IsTransition() const { return lookup_.IsTransition(); }
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
2917 } 3032 }
2918 3033
2919 private: 3034 private:
2920 HGraphBuilder* builder_; 3035 HGraphBuilder* builder_;
2921 }; 3036 };
2922 3037
2923 3038
2924 } } // namespace v8::internal 3039 } } // namespace v8::internal
2925 3040
2926 #endif // V8_HYDROGEN_H_ 3041 #endif // V8_HYDROGEN_H_
OLDNEW
« no previous file with comments | « src/globals.h ('k') | src/hydrogen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698