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

Side by Side Diff: runtime/vm/object.cc

Issue 2044423003: Remember inside an ICData if it is for a static call or an instance call (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 6 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 | « runtime/vm/object.h ('k') | runtime/vm/object_reload.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 (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/object.h" 5 #include "vm/object.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/become.h" 10 #include "vm/become.h"
(...skipping 12540 matching lines...) Expand 10 before | Expand all | Expand 10 after
12551 } 12551 }
12552 12552
12553 12553
12554 void ICData::AddDeoptReason(DeoptReasonId reason) const { 12554 void ICData::AddDeoptReason(DeoptReasonId reason) const {
12555 if (reason <= kLastRecordedDeoptReason) { 12555 if (reason <= kLastRecordedDeoptReason) {
12556 SetDeoptReasons(DeoptReasons() | (1 << reason)); 12556 SetDeoptReasons(DeoptReasons() | (1 << reason));
12557 } 12557 }
12558 } 12558 }
12559 12559
12560 12560
12561 void ICData::SetIsStaticCall(bool static_call) const {
12562 StoreNonPointer(&raw_ptr()->state_bits_,
12563 StaticCallBit::update(static_call, raw_ptr()->state_bits_));
12564 }
12565
12566
12567 bool ICData::is_static_call() const {
12568 return StaticCallBit::decode(raw_ptr()->state_bits_);
12569 }
12570
12571
12561 void ICData::set_state_bits(uint32_t bits) const { 12572 void ICData::set_state_bits(uint32_t bits) const {
12562 StoreNonPointer(&raw_ptr()->state_bits_, bits); 12573 StoreNonPointer(&raw_ptr()->state_bits_, bits);
12563 } 12574 }
12564 12575
12565 12576
12566 intptr_t ICData::TestEntryLengthFor(intptr_t num_args) { 12577 intptr_t ICData::TestEntryLengthFor(intptr_t num_args) {
12567 return num_args + 1 /* target function*/ + 1 /* frequency */; 12578 return num_args + 1 /* target function*/ + 1 /* frequency */;
12568 } 12579 }
12569 12580
12570 12581
(...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after
13363 } 13374 }
13364 13375
13365 13376
13366 13377
13367 // Does not initialize ICData array. 13378 // Does not initialize ICData array.
13368 RawICData* ICData::NewDescriptor(Zone* zone, 13379 RawICData* ICData::NewDescriptor(Zone* zone,
13369 const Function& owner, 13380 const Function& owner,
13370 const String& target_name, 13381 const String& target_name,
13371 const Array& arguments_descriptor, 13382 const Array& arguments_descriptor,
13372 intptr_t deopt_id, 13383 intptr_t deopt_id,
13373 intptr_t num_args_tested) { 13384 intptr_t num_args_tested,
13385 bool is_static_call) {
13374 ASSERT(!owner.IsNull()); 13386 ASSERT(!owner.IsNull());
13375 ASSERT(!target_name.IsNull()); 13387 ASSERT(!target_name.IsNull());
13376 ASSERT(!arguments_descriptor.IsNull()); 13388 ASSERT(!arguments_descriptor.IsNull());
13377 ASSERT(Object::icdata_class() != Class::null()); 13389 ASSERT(Object::icdata_class() != Class::null());
13378 ASSERT(num_args_tested >= 0); 13390 ASSERT(num_args_tested >= 0);
13379 ICData& result = ICData::Handle(zone); 13391 ICData& result = ICData::Handle(zone);
13380 { 13392 {
13381 // IC data objects are long living objects, allocate them in old generation. 13393 // IC data objects are long living objects, allocate them in old generation.
13382 RawObject* raw = Object::Allocate(ICData::kClassId, 13394 RawObject* raw = Object::Allocate(ICData::kClassId,
13383 ICData::InstanceSize(), 13395 ICData::InstanceSize(),
13384 Heap::kOld); 13396 Heap::kOld);
13385 NoSafepointScope no_safepoint; 13397 NoSafepointScope no_safepoint;
13386 result ^= raw; 13398 result ^= raw;
13387 } 13399 }
13388 result.set_owner(owner); 13400 result.set_owner(owner);
13389 result.set_target_name(target_name); 13401 result.set_target_name(target_name);
13390 result.set_arguments_descriptor(arguments_descriptor); 13402 result.set_arguments_descriptor(arguments_descriptor);
13391 result.set_deopt_id(deopt_id); 13403 result.set_deopt_id(deopt_id);
13392 result.set_state_bits(0); 13404 result.set_state_bits(0);
13393 #if defined(TAG_IC_DATA) 13405 #if defined(TAG_IC_DATA)
13394 result.set_tag(-1); 13406 result.set_tag(-1);
13395 #endif 13407 #endif
13408 result.SetIsStaticCall(is_static_call);
13396 result.SetNumArgsTested(num_args_tested); 13409 result.SetNumArgsTested(num_args_tested);
13397 return result.raw(); 13410 return result.raw();
13398 } 13411 }
13399 13412
13400 13413
13401 bool ICData::IsImmutable() const { 13414 bool ICData::IsImmutable() const {
13402 const Array& data = Array::Handle(ic_data()); 13415 const Array& data = Array::Handle(ic_data());
13403 return data.IsImmutable(); 13416 return data.IsImmutable();
13404 } 13417 }
13405 13418
(...skipping 24 matching lines...) Expand all
13430 result.set_tag(-1); 13443 result.set_tag(-1);
13431 #endif 13444 #endif
13432 return result.raw(); 13445 return result.raw();
13433 } 13446 }
13434 13447
13435 13448
13436 RawICData* ICData::New(const Function& owner, 13449 RawICData* ICData::New(const Function& owner,
13437 const String& target_name, 13450 const String& target_name,
13438 const Array& arguments_descriptor, 13451 const Array& arguments_descriptor,
13439 intptr_t deopt_id, 13452 intptr_t deopt_id,
13440 intptr_t num_args_tested) { 13453 intptr_t num_args_tested,
13454 bool is_static_call) {
13441 Zone* zone = Thread::Current()->zone(); 13455 Zone* zone = Thread::Current()->zone();
13442 const ICData& result = ICData::Handle(zone, 13456 const ICData& result = ICData::Handle(zone,
13443 NewDescriptor(zone, 13457 NewDescriptor(zone,
13444 owner, 13458 owner,
13445 target_name, 13459 target_name,
13446 arguments_descriptor, 13460 arguments_descriptor,
13447 deopt_id, 13461 deopt_id,
13448 num_args_tested)); 13462 num_args_tested,
13463 is_static_call));
13449 result.set_ic_data_array( 13464 result.set_ic_data_array(
13450 Array::Handle(zone, NewEmptyICDataArray(num_args_tested))); 13465 Array::Handle(zone, NewEmptyICDataArray(num_args_tested)));
13451 return result.raw(); 13466 return result.raw();
13452 } 13467 }
13453 13468
13454 13469
13455 RawICData* ICData::NewFrom(const ICData& from, intptr_t num_args_tested) { 13470 RawICData* ICData::NewFrom(const ICData& from, intptr_t num_args_tested) {
13456 const ICData& result = ICData::Handle(ICData::New( 13471 const ICData& result = ICData::Handle(ICData::New(
13457 Function::Handle(from.Owner()), 13472 Function::Handle(from.Owner()),
13458 String::Handle(from.target_name()), 13473 String::Handle(from.target_name()),
13459 Array::Handle(from.arguments_descriptor()), 13474 Array::Handle(from.arguments_descriptor()),
13460 from.deopt_id(), 13475 from.deopt_id(),
13461 num_args_tested)); 13476 num_args_tested,
13477 from.is_static_call()));
13462 // Copy deoptimization reasons. 13478 // Copy deoptimization reasons.
13463 result.SetDeoptReasons(from.DeoptReasons()); 13479 result.SetDeoptReasons(from.DeoptReasons());
13464 return result.raw(); 13480 return result.raw();
13465 } 13481 }
13466 13482
13467 13483
13468 RawICData* ICData::Clone(const ICData& from) { 13484 RawICData* ICData::Clone(const ICData& from) {
13469 Zone* zone = Thread::Current()->zone(); 13485 Zone* zone = Thread::Current()->zone();
13470 const ICData& result = ICData::Handle(ICData::NewDescriptor( 13486 const ICData& result = ICData::Handle(ICData::NewDescriptor(
13471 zone, 13487 zone,
13472 Function::Handle(zone, from.Owner()), 13488 Function::Handle(zone, from.Owner()),
13473 String::Handle(zone, from.target_name()), 13489 String::Handle(zone, from.target_name()),
13474 Array::Handle(zone, from.arguments_descriptor()), 13490 Array::Handle(zone, from.arguments_descriptor()),
13475 from.deopt_id(), 13491 from.deopt_id(),
13476 from.NumArgsTested())); 13492 from.NumArgsTested(),
13493 from.is_static_call()));
13477 // Clone entry array. 13494 // Clone entry array.
13478 const Array& from_array = Array::Handle(zone, from.ic_data()); 13495 const Array& from_array = Array::Handle(zone, from.ic_data());
13479 const intptr_t len = from_array.Length(); 13496 const intptr_t len = from_array.Length();
13480 const Array& cloned_array = 13497 const Array& cloned_array =
13481 Array::Handle(zone, Array::New(len, Heap::kOld)); 13498 Array::Handle(zone, Array::New(len, Heap::kOld));
13482 Object& obj = Object::Handle(zone); 13499 Object& obj = Object::Handle(zone);
13483 for (intptr_t i = 0; i < len; i++) { 13500 for (intptr_t i = 0; i < len; i++) {
13484 obj = from_array.At(i); 13501 obj = from_array.At(i);
13485 cloned_array.SetAt(i, obj); 13502 cloned_array.SetAt(i, obj);
13486 } 13503 }
(...skipping 9150 matching lines...) Expand 10 before | Expand all | Expand 10 after
22637 return UserTag::null(); 22654 return UserTag::null();
22638 } 22655 }
22639 22656
22640 22657
22641 const char* UserTag::ToCString() const { 22658 const char* UserTag::ToCString() const {
22642 const String& tag_label = String::Handle(label()); 22659 const String& tag_label = String::Handle(label());
22643 return tag_label.ToCString(); 22660 return tag_label.ToCString();
22644 } 22661 }
22645 22662
22646 } // namespace dart 22663 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/object_reload.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698