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

Side by Side Diff: vm/object.cc

Issue 8379013: Implement new inline cache. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: '' Created 9 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 | Annotate | Revision Log
« no previous file with comments | « vm/object.h ('k') | vm/raw_object.h » ('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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 "vm/assembler.h" 7 #include "vm/assembler.h"
8 #include "vm/assert.h" 8 #include "vm/assert.h"
9 #include "vm/bigint_operations.h" 9 #include "vm/bigint_operations.h"
10 #include "vm/bootstrap.h" 10 #include "vm/bootstrap.h"
11 #include "vm/code_generator.h" 11 #include "vm/code_generator.h"
12 #include "vm/code_index_table.h" 12 #include "vm/code_index_table.h"
13 #include "vm/code_patcher.h" 13 #include "vm/code_patcher.h"
14 #include "vm/compiler.h" 14 #include "vm/compiler.h"
15 #include "vm/compiler_stats.h" 15 #include "vm/compiler_stats.h"
16 #include "vm/class_finalizer.h" 16 #include "vm/class_finalizer.h"
17 #include "vm/dart.h" 17 #include "vm/dart.h"
18 #include "vm/debuginfo.h" 18 #include "vm/debuginfo.h"
19 #include "vm/growable_array.h" 19 #include "vm/growable_array.h"
20 #include "vm/heap.h" 20 #include "vm/heap.h"
21 #include "vm/ic_stubs.h" 21 #include "vm/ic_data.h"
22 #include "vm/object_store.h" 22 #include "vm/object_store.h"
23 #include "vm/parser.h" 23 #include "vm/parser.h"
24 #include "vm/runtime_entry.h" 24 #include "vm/runtime_entry.h"
25 #include "vm/scopes.h" 25 #include "vm/scopes.h"
26 #include "vm/timer.h" 26 #include "vm/timer.h"
27 #include "vm/unicode.h" 27 #include "vm/unicode.h"
28 28
29 namespace dart { 29 namespace dart {
30 30
31 DEFINE_FLAG(bool, expose_core_impl, false, 31 DEFINE_FLAG(bool, expose_core_impl, false,
(...skipping 4250 matching lines...) Expand 10 before | Expand all | Expand 10 after
4282 Code& result = Code::Handle(); 4282 Code& result = Code::Handle();
4283 { 4283 {
4284 uword size = Code::InstanceSize(pointer_offsets_length); 4284 uword size = Code::InstanceSize(pointer_offsets_length);
4285 RawObject* raw = Object::Allocate(cls, size, Heap::kOld); 4285 RawObject* raw = Object::Allocate(cls, size, Heap::kOld);
4286 NoGCScope no_gc; 4286 NoGCScope no_gc;
4287 result ^= raw; 4287 result ^= raw;
4288 result.set_pointer_offsets_length(pointer_offsets_length); 4288 result.set_pointer_offsets_length(pointer_offsets_length);
4289 result.set_is_optimized(false); 4289 result.set_is_optimized(false);
4290 } 4290 }
4291 result.raw_ptr()->ic_data_ = Array::Empty(); 4291 result.raw_ptr()->ic_data_ = Array::Empty();
4292 result.raw_ptr()->class_ic_stubs_ = Array::Empty();
4293 return result.raw(); 4292 return result.raw();
4294 } 4293 }
4295 4294
4296 4295
4297 RawCode* Code::FinalizeCode(const char* name, Assembler* assembler) { 4296 RawCode* Code::FinalizeCode(const char* name, Assembler* assembler) {
4298 ASSERT(assembler != NULL); 4297 ASSERT(assembler != NULL);
4299 4298
4300 // Allocate the Instructions object. 4299 // Allocate the Instructions object.
4301 Instructions& instrs = 4300 Instructions& instrs =
4302 Instructions::ZoneHandle(Instructions::New(assembler->CodeSize())); 4301 Instructions::ZoneHandle(Instructions::New(assembler->CodeSize()));
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
4364 RawArray* Code::ic_data() const { 4363 RawArray* Code::ic_data() const {
4365 return raw_ptr()->ic_data_; 4364 return raw_ptr()->ic_data_;
4366 } 4365 }
4367 4366
4368 4367
4369 void Code::set_ic_data(const Array& ic_data) const { 4368 void Code::set_ic_data(const Array& ic_data) const {
4370 ASSERT(!ic_data.IsNull()); 4369 ASSERT(!ic_data.IsNull());
4371 StorePointer(&raw_ptr()->ic_data_, ic_data.raw()); 4370 StorePointer(&raw_ptr()->ic_data_, ic_data.raw());
4372 } 4371 }
4373 4372
4374
4375 RawArray* Code::class_ic_stubs() const {
4376 return raw_ptr()->class_ic_stubs_;
4377 }
4378
4379
4380 void Code::set_class_ic_stubs(const Array& class_ic_stubs) const {
4381 ASSERT(!class_ic_stubs.IsNull());
4382 StorePointer(&raw_ptr()->class_ic_stubs_, class_ic_stubs.raw());
4383 }
4384
4385
4386 intptr_t Code::GetTokenIndexOfPC(uword pc) const { 4373 intptr_t Code::GetTokenIndexOfPC(uword pc) const {
4387 intptr_t token_index = -1; 4374 intptr_t token_index = -1;
4388 const PcDescriptors& descriptors = PcDescriptors::Handle(pc_descriptors()); 4375 const PcDescriptors& descriptors = PcDescriptors::Handle(pc_descriptors());
4389 for (intptr_t i = 0; i < descriptors.Length(); i++) { 4376 for (intptr_t i = 0; i < descriptors.Length(); i++) {
4390 if (static_cast<uword>(descriptors.PC(i)) == pc) { 4377 if (static_cast<uword>(descriptors.PC(i)) == pc) {
4391 token_index = descriptors.TokenIndex(i); 4378 token_index = descriptors.TokenIndex(i);
4392 break; 4379 break;
4393 } 4380 }
4394 } 4381 }
4395 return token_index; 4382 return token_index;
4396 } 4383 }
4397 4384
4398 4385
4399 uword Code::GetDeoptPcAtNodeId(intptr_t node_id) const { 4386 uword Code::GetDeoptPcAtNodeId(intptr_t node_id) const {
4400 const PcDescriptors& descriptors = PcDescriptors::Handle(pc_descriptors()); 4387 const PcDescriptors& descriptors = PcDescriptors::Handle(pc_descriptors());
4401 for (intptr_t i = 0; i < descriptors.Length(); i++) { 4388 for (intptr_t i = 0; i < descriptors.Length(); i++) {
4402 if ((descriptors.NodeId(i) == node_id) && 4389 if ((descriptors.NodeId(i) == node_id) &&
4403 (descriptors.DescriptorKind(i) == PcDescriptors::kDeopt)) { 4390 (descriptors.DescriptorKind(i) == PcDescriptors::kDeopt)) {
4404 return descriptors.PC(i); 4391 return descriptors.PC(i);
4405 } 4392 }
4406 } 4393 }
4407 return 0; 4394 return 0;
4408 } 4395 }
4409 4396
4410 4397
4411 const char* Code::ToCString() const { 4398 const char* Code::ToCString() const {
4412 const char* kFormat = "Code entry:0x%d icstubs: %d"; 4399 const char* kFormat = "Code entry:0x%d";
4413 intptr_t len = OS::SNPrint(NULL, 0, kFormat, 4400 intptr_t len = OS::SNPrint(NULL, 0, kFormat, EntryPoint());
4414 EntryPoint(),
4415 (Array::Handle(class_ic_stubs()).Length() / 2)) + 1;
4416 char* chars = reinterpret_cast<char*>( 4401 char* chars = reinterpret_cast<char*>(
4417 Isolate::Current()->current_zone()->Allocate(len)); 4402 Isolate::Current()->current_zone()->Allocate(len));
4418 OS::SNPrint(chars, len, kFormat, 4403 OS::SNPrint(chars, len, kFormat, EntryPoint());
4419 EntryPoint(),
4420 (Array::Handle(class_ic_stubs()).Length() / 2));
4421 return chars; 4404 return chars;
4422 } 4405 }
4423 4406
4424 4407
4425 uword Code::GetPatchCodePc() const { 4408 uword Code::GetPatchCodePc() const {
4426 const PcDescriptors& descriptors = PcDescriptors::Handle(pc_descriptors()); 4409 const PcDescriptors& descriptors = PcDescriptors::Handle(pc_descriptors());
4427 for (intptr_t i = 0; i < descriptors.Length(); i++) { 4410 for (intptr_t i = 0; i < descriptors.Length(); i++) {
4428 if (descriptors.DescriptorKind(i) == PcDescriptors::kPatchCode) { 4411 if (descriptors.DescriptorKind(i) == PcDescriptors::kPatchCode) {
4429 return descriptors.PC(i); 4412 return descriptors.PC(i);
4430 } 4413 }
(...skipping 13 matching lines...) Expand all
4444 } 4427 }
4445 4428
4446 4429
4447 void Code::ExtractTypesAtIcCalls( 4430 void Code::ExtractTypesAtIcCalls(
4448 GrowableArray<intptr_t>* node_ids, 4431 GrowableArray<intptr_t>* node_ids,
4449 GrowableArray<ZoneGrowableArray<const Class*>*>* type_arrays) const { 4432 GrowableArray<ZoneGrowableArray<const Class*>*>* type_arrays) const {
4450 ASSERT(node_ids != NULL); 4433 ASSERT(node_ids != NULL);
4451 ASSERT(type_arrays != NULL); 4434 ASSERT(type_arrays != NULL);
4452 const PcDescriptors& descriptors = 4435 const PcDescriptors& descriptors =
4453 PcDescriptors::Handle(this->pc_descriptors()); 4436 PcDescriptors::Handle(this->pc_descriptors());
4454 String& function_name = String::Handle();
4455 for (intptr_t i = 0; i < descriptors.Length(); i++) { 4437 for (intptr_t i = 0; i < descriptors.Length(); i++) {
4456 if (descriptors.DescriptorKind(i) == PcDescriptors::kIcCall) { 4438 if (descriptors.DescriptorKind(i) == PcDescriptors::kIcCall) {
4457 int num_arguments = -1; 4439 ICData ic_data(Array::Handle(
4458 int num_named_arguments = -1; 4440 CodePatcher::GetInstanceCallIcDataAt(descriptors.PC(i))));
4459 uword caller_target = 0; 4441 ASSERT(ic_data.NumberOfArgumentsChecked() == 1);
4460 CodePatcher::GetInstanceCallAt(descriptors.PC(i), 4442 int len = ic_data.NumberOfChecks();
4461 &function_name,
4462 &num_arguments,
4463 &num_named_arguments,
4464 &caller_target);
4465 GrowableArray<const Class*> classes;
4466 GrowableArray<const Function*> targets;
4467 bool is_ic = ICStubs::RecognizeICStub(caller_target, &classes, &targets);
4468 ASSERT(is_ic);
4469 ZoneGrowableArray<const Class*>* types = 4443 ZoneGrowableArray<const Class*>* types =
4470 new ZoneGrowableArray<const Class*>(); 4444 new ZoneGrowableArray<const Class*>();
4471 for (intptr_t k = 0; k < classes.length(); k++) { 4445 Function& target = Function::Handle();
4472 types->Add(classes[k]); 4446 for (intptr_t k = 0; k < len; k++) {
4447 GrowableArray<const Class*> classes;
4448 ic_data.GetCheckAt(k, &classes, &target);
4449 ASSERT(classes.length() == 1);
4450 types->Add(classes[0]);
4473 } 4451 }
4474 node_ids->Add(descriptors.NodeId(i)); 4452 node_ids->Add(descriptors.NodeId(i));
4475 type_arrays->Add(types); 4453 type_arrays->Add(types);
4476 } 4454 }
4477 } 4455 }
4478 } 4456 }
4479 4457
4480 4458
4481 RawContext* Context::New(intptr_t num_variables, Heap::Space space) { 4459 RawContext* Context::New(intptr_t num_variables, Heap::Space space) {
4482 ASSERT(num_variables >= 0); 4460 ASSERT(num_variables >= 0);
(...skipping 2323 matching lines...) Expand 10 before | Expand all | Expand 10 after
6806 const String& str = String::Handle(pattern()); 6784 const String& str = String::Handle(pattern());
6807 const char* format = "JSRegExp: pattern=%s flags=%s"; 6785 const char* format = "JSRegExp: pattern=%s flags=%s";
6808 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); 6786 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags());
6809 char* chars = reinterpret_cast<char*>( 6787 char* chars = reinterpret_cast<char*>(
6810 Isolate::Current()->current_zone()->Allocate(len + 1)); 6788 Isolate::Current()->current_zone()->Allocate(len + 1));
6811 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); 6789 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags());
6812 return chars; 6790 return chars;
6813 } 6791 }
6814 6792
6815 } // namespace dart 6793 } // namespace dart
OLDNEW
« no previous file with comments | « vm/object.h ('k') | vm/raw_object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698