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

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

Issue 1799793002: Precompilation: Have instances calls load the entry point and Code object from the ic data array in… (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 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 (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/cpu.h" 10 #include "vm/cpu.h"
(...skipping 12311 matching lines...) Expand 10 before | Expand all | Expand 10 after
12322 if ((receiver_class_id == kSmiCid) && (data_pos > 0)) { 12322 if ((receiver_class_id == kSmiCid) && (data_pos > 0)) {
12323 ASSERT(GetReceiverClassIdAt(0) != kSmiCid); 12323 ASSERT(GetReceiverClassIdAt(0) != kSmiCid);
12324 // Move class occupying position 0 to the data_pos. 12324 // Move class occupying position 0 to the data_pos.
12325 for (intptr_t i = 0; i < TestEntryLength(); i++) { 12325 for (intptr_t i = 0; i < TestEntryLength(); i++) {
12326 data.SetAt(data_pos + i, Object::Handle(data.At(i))); 12326 data.SetAt(data_pos + i, Object::Handle(data.At(i)));
12327 } 12327 }
12328 // Insert kSmiCid in position 0. 12328 // Insert kSmiCid in position 0.
12329 data_pos = 0; 12329 data_pos = 0;
12330 } 12330 }
12331 data.SetAt(data_pos, Smi::Handle(Smi::New(receiver_class_id))); 12331 data.SetAt(data_pos, Smi::Handle(Smi::New(receiver_class_id)));
12332 data.SetAt(data_pos + 1, target); 12332 if (Isolate::Current()->compilation_allowed()) {
12333 data.SetAt(data_pos + 2, Smi::Handle(Smi::New(count))); 12333 data.SetAt(data_pos + 1, target);
12334 data.SetAt(data_pos + 2, Smi::Handle(Smi::New(count)));
12335 } else {
srdjan 2016/03/15 19:15:48 Add a comment, that this is for precompilation onl
rmacnak 2016/03/16 18:21:31 Done.
12336 const Code& code = Code::Handle(target.CurrentCode());
12337 const Smi& entry_point =
12338 Smi::Handle(reinterpret_cast<RawSmi*>(code.EntryPoint()));
srdjan 2016/03/15 19:15:48 Add check that this is a valid Smi value.
rmacnak 2016/03/16 18:21:31 Added Smi::FromAlignedAddress.
12339 data.SetAt(data_pos + 1, code);
12340 data.SetAt(data_pos + 2, entry_point);
12341 }
12334 // Multithreaded access to ICData requires setting of array to be the last 12342 // Multithreaded access to ICData requires setting of array to be the last
12335 // operation. 12343 // operation.
12336 set_ic_data_array(data); 12344 set_ic_data_array(data);
12337 } 12345 }
12338 12346
12339 12347
12340 void ICData::GetCheckAt(intptr_t index, 12348 void ICData::GetCheckAt(intptr_t index,
12341 GrowableArray<intptr_t>* class_ids, 12349 GrowableArray<intptr_t>* class_ids,
12342 Function* target) const { 12350 Function* target) const {
12343 ASSERT(index < NumberOfChecks()); 12351 ASSERT(index < NumberOfChecks());
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
12397 intptr_t ICData::GetReceiverClassIdAt(intptr_t index) const { 12405 intptr_t ICData::GetReceiverClassIdAt(intptr_t index) const {
12398 ASSERT(index < NumberOfChecks()); 12406 ASSERT(index < NumberOfChecks());
12399 const intptr_t data_pos = index * TestEntryLength(); 12407 const intptr_t data_pos = index * TestEntryLength();
12400 NoSafepointScope no_safepoint; 12408 NoSafepointScope no_safepoint;
12401 RawArray* raw_data = ic_data(); 12409 RawArray* raw_data = ic_data();
12402 return Smi::Value(Smi::RawCast(raw_data->ptr()->data()[data_pos])); 12410 return Smi::Value(Smi::RawCast(raw_data->ptr()->data()[data_pos]));
12403 } 12411 }
12404 12412
12405 12413
12406 RawFunction* ICData::GetTargetAt(intptr_t index) const { 12414 RawFunction* ICData::GetTargetAt(intptr_t index) const {
12415 ASSERT(Isolate::Current()->compilation_allowed());
12407 const intptr_t data_pos = index * TestEntryLength() + NumArgsTested(); 12416 const intptr_t data_pos = index * TestEntryLength() + NumArgsTested();
12408 ASSERT(Object::Handle(Array::Handle(ic_data()).At(data_pos)).IsFunction()); 12417 ASSERT(Object::Handle(Array::Handle(ic_data()).At(data_pos)).IsFunction());
12409 12418
12410 NoSafepointScope no_safepoint; 12419 NoSafepointScope no_safepoint;
12411 RawArray* raw_data = ic_data(); 12420 RawArray* raw_data = ic_data();
12412 return reinterpret_cast<RawFunction*>(raw_data->ptr()->data()[data_pos]); 12421 return reinterpret_cast<RawFunction*>(raw_data->ptr()->data()[data_pos]);
12413 } 12422 }
12414 12423
12415 12424
12425 RawObject* ICData::GetTargetOrCodeAt(intptr_t index) const {
12426 const intptr_t data_pos = index * TestEntryLength() + NumArgsTested();
12427
12428 NoSafepointScope no_safepoint;
12429 RawArray* raw_data = ic_data();
12430 return reinterpret_cast<RawObject*>(raw_data->ptr()->data()[data_pos]);
srdjan 2016/03/15 19:15:48 Do you need the cast? Isn't raw_data->ptr()->data(
rmacnak 2016/03/16 18:21:31 No, removed.
12431 }
12432
12433
12416 void ICData::IncrementCountAt(intptr_t index, intptr_t value) const { 12434 void ICData::IncrementCountAt(intptr_t index, intptr_t value) const {
12417 ASSERT(0 <= value); 12435 ASSERT(0 <= value);
12418 ASSERT(value <= Smi::kMaxValue); 12436 ASSERT(value <= Smi::kMaxValue);
12419 SetCountAt(index, Utils::Minimum(GetCountAt(index) + value, Smi::kMaxValue)); 12437 SetCountAt(index, Utils::Minimum(GetCountAt(index) + value, Smi::kMaxValue));
12420 } 12438 }
12421 12439
12422 12440
12423 void ICData::SetCountAt(intptr_t index, intptr_t value) const { 12441 void ICData::SetCountAt(intptr_t index, intptr_t value) const {
12424 ASSERT(0 <= value); 12442 ASSERT(0 <= value);
12425 ASSERT(value <= Smi::kMaxValue); 12443 ASSERT(value <= Smi::kMaxValue);
12426 12444
12427 const Array& data = Array::Handle(ic_data()); 12445 const Array& data = Array::Handle(ic_data());
12428 const intptr_t data_pos = index * TestEntryLength() + 12446 const intptr_t data_pos = index * TestEntryLength() +
12429 CountIndexFor(NumArgsTested()); 12447 CountIndexFor(NumArgsTested());
12430 data.SetAt(data_pos, Smi::Handle(Smi::New(value))); 12448 data.SetAt(data_pos, Smi::Handle(Smi::New(value)));
12431 } 12449 }
12432 12450
12433 12451
12452 void ICData::SetCodeAt(intptr_t index, const Code& value) const {
12453 ASSERT(!Isolate::Current()->compilation_allowed());
12454 const Array& data = Array::Handle(ic_data());
12455 const intptr_t data_pos = index * TestEntryLength() +
12456 CodeIndexFor(NumArgsTested());
12457 data.SetAt(data_pos, value);
12458 }
12459
12460
12461 void ICData::SetEntryPointAt(intptr_t index, const Smi& value) const {
12462 ASSERT(!Isolate::Current()->compilation_allowed());
12463 const Array& data = Array::Handle(ic_data());
12464 const intptr_t data_pos = index * TestEntryLength() +
12465 EntryPointIndexFor(NumArgsTested());
12466 data.SetAt(data_pos, value);
srdjan 2016/03/15 19:15:48 Maybe put this two functions after all count funct
rmacnak 2016/03/16 18:21:31 Done.
12467 }
12468
12469
12434 intptr_t ICData::GetCountAt(intptr_t index) const { 12470 intptr_t ICData::GetCountAt(intptr_t index) const {
12471 ASSERT(Isolate::Current()->compilation_allowed());
12435 const Array& data = Array::Handle(ic_data()); 12472 const Array& data = Array::Handle(ic_data());
12436 const intptr_t data_pos = index * TestEntryLength() + 12473 const intptr_t data_pos = index * TestEntryLength() +
12437 CountIndexFor(NumArgsTested()); 12474 CountIndexFor(NumArgsTested());
12438 return Smi::Value(Smi::RawCast(data.At(data_pos))); 12475 return Smi::Value(Smi::RawCast(data.At(data_pos)));
12439 } 12476 }
12440 12477
12441 12478
12442 intptr_t ICData::AggregateCount() const { 12479 intptr_t ICData::AggregateCount() const {
12443 if (IsNull()) return 0; 12480 if (IsNull()) return 0;
12444 const intptr_t len = NumberOfChecks(); 12481 const intptr_t len = NumberOfChecks();
(...skipping 9472 matching lines...) Expand 10 before | Expand all | Expand 10 after
21917 return UserTag::null(); 21954 return UserTag::null();
21918 } 21955 }
21919 21956
21920 21957
21921 const char* UserTag::ToCString() const { 21958 const char* UserTag::ToCString() const {
21922 const String& tag_label = String::Handle(label()); 21959 const String& tag_label = String::Handle(label());
21923 return tag_label.ToCString(); 21960 return tag_label.ToCString();
21924 } 21961 }
21925 21962
21926 } // namespace dart 21963 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/precompiler.h » ('j') | runtime/vm/precompiler.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698