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

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

Issue 1261673004: Non-tree-shaking --precompile. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 4 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/parser.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/cpu.h" 10 #include "vm/cpu.h"
(...skipping 7202 matching lines...) Expand 10 before | Expand all | Expand 10 after
7213 result.set_value(Object::null_instance()); 7213 result.set_value(Object::null_instance());
7214 } else { 7214 } else {
7215 result.SetOffset(0); 7215 result.SetOffset(0);
7216 } 7216 }
7217 result.set_is_final(is_final); 7217 result.set_is_final(is_final);
7218 result.set_is_const(is_const); 7218 result.set_is_const(is_const);
7219 result.set_is_synthetic(is_synthetic); 7219 result.set_is_synthetic(is_synthetic);
7220 result.set_owner(owner); 7220 result.set_owner(owner);
7221 result.set_token_pos(token_pos); 7221 result.set_token_pos(token_pos);
7222 result.set_has_initializer(false); 7222 result.set_has_initializer(false);
7223 result.set_initializer(Function::Handle());
7223 result.set_is_unboxing_candidate(true); 7224 result.set_is_unboxing_candidate(true);
7224 result.set_guarded_cid(FLAG_use_field_guards ? kIllegalCid : kDynamicCid); 7225 result.set_guarded_cid(FLAG_use_field_guards ? kIllegalCid : kDynamicCid);
7225 result.set_is_nullable(FLAG_use_field_guards ? false : true); 7226 result.set_is_nullable(FLAG_use_field_guards ? false : true);
7226 result.set_guarded_list_length_in_object_offset(Field::kUnknownLengthOffset); 7227 result.set_guarded_list_length_in_object_offset(Field::kUnknownLengthOffset);
7227 // Presently, we only attempt to remember the list length for final fields. 7228 // Presently, we only attempt to remember the list length for final fields.
7228 if (is_final && FLAG_use_field_guards) { 7229 if (is_final && FLAG_use_field_guards) {
7229 result.set_guarded_list_length(Field::kUnknownFixedLength); 7230 result.set_guarded_list_length(Field::kUnknownFixedLength);
7230 } else { 7231 } else {
7231 result.set_guarded_list_length(Field::kNoFixedLength); 7232 result.set_guarded_list_length(Field::kNoFixedLength);
7232 } 7233 }
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
7509 } 7510 }
7510 7511
7511 7512
7512 bool Field::IsUninitialized() const { 7513 bool Field::IsUninitialized() const {
7513 const Instance& value = Instance::Handle(raw_ptr()->value_); 7514 const Instance& value = Instance::Handle(raw_ptr()->value_);
7514 ASSERT(value.raw() != Object::transition_sentinel().raw()); 7515 ASSERT(value.raw() != Object::transition_sentinel().raw());
7515 return value.raw() == Object::sentinel().raw(); 7516 return value.raw() == Object::sentinel().raw();
7516 } 7517 }
7517 7518
7518 7519
7520 void Field::set_initializer(const Function& initializer) const {
7521 StorePointer(&raw_ptr()->initializer_, initializer.raw());
7522 }
7523
7524
7519 void Field::EvaluateInitializer() const { 7525 void Field::EvaluateInitializer() const {
7520 ASSERT(is_static()); 7526 ASSERT(is_static());
7521 if (value() == Object::sentinel().raw()) { 7527 if (value() == Object::sentinel().raw()) {
7522 set_value(Object::transition_sentinel()); 7528 set_value(Object::transition_sentinel());
7523 Object& value = Object::Handle(Compiler::EvaluateStaticInitializer(*this)); 7529 Object& value = Object::Handle(Compiler::EvaluateStaticInitializer(*this));
7524 if (value.IsError()) { 7530 if (value.IsError()) {
7525 set_value(Object::null_instance()); 7531 set_value(Object::null_instance());
7526 Exceptions::PropagateError(Error::Cast(value)); 7532 Exceptions::PropagateError(Error::Cast(value));
7527 UNREACHABLE(); 7533 UNREACHABLE();
7528 } 7534 }
(...skipping 5303 matching lines...) Expand 10 before | Expand all | Expand 10 after
12832 result.set_lazy_deopt_pc_offset(kInvalidPc); 12838 result.set_lazy_deopt_pc_offset(kInvalidPc);
12833 result.set_pc_descriptors(Object::empty_descriptors()); 12839 result.set_pc_descriptors(Object::empty_descriptors());
12834 } 12840 }
12835 return result.raw(); 12841 return result.raw();
12836 } 12842 }
12837 12843
12838 12844
12839 RawCode* Code::FinalizeCode(const char* name, 12845 RawCode* Code::FinalizeCode(const char* name,
12840 Assembler* assembler, 12846 Assembler* assembler,
12841 bool optimized) { 12847 bool optimized) {
12848 Isolate* isolate = Isolate::Current();
12849 if (!isolate->compilation_allowed()) {
12850 FATAL1("Precompilation missed code %s\n", name);
12851 }
12852
12842 ASSERT(assembler != NULL); 12853 ASSERT(assembler != NULL);
12843 const ObjectPool& object_pool = 12854 const ObjectPool& object_pool =
12844 ObjectPool::Handle(assembler->object_pool_wrapper().MakeObjectPool()); 12855 ObjectPool::Handle(assembler->object_pool_wrapper().MakeObjectPool());
12845 12856
12846 // Allocate the Code and Instructions objects. Code is allocated first 12857 // Allocate the Code and Instructions objects. Code is allocated first
12847 // because a GC during allocation of the code will leave the instruction 12858 // because a GC during allocation of the code will leave the instruction
12848 // pages read-only. 12859 // pages read-only.
12849 intptr_t pointer_offset_count = assembler->CountPointerOffsets(); 12860 intptr_t pointer_offset_count = assembler->CountPointerOffsets();
12850 Code& code = Code::ZoneHandle(Code::New(pointer_offset_count)); 12861 Code& code = Code::ZoneHandle(Code::New(pointer_offset_count));
12851 Instructions& instrs = 12862 Instructions& instrs =
12852 Instructions::ZoneHandle(Instructions::New(assembler->CodeSize())); 12863 Instructions::ZoneHandle(Instructions::New(assembler->CodeSize()));
12853 INC_STAT(Isolate::Current(), total_instr_size, assembler->CodeSize()); 12864 INC_STAT(isolate, total_instr_size, assembler->CodeSize());
12854 INC_STAT(Isolate::Current(), total_code_size, assembler->CodeSize()); 12865 INC_STAT(isolate, total_code_size, assembler->CodeSize());
12855 12866
12856 // Copy the instructions into the instruction area and apply all fixups. 12867 // Copy the instructions into the instruction area and apply all fixups.
12857 // Embedded pointers are still in handles at this point. 12868 // Embedded pointers are still in handles at this point.
12858 MemoryRegion region(reinterpret_cast<void*>(instrs.EntryPoint()), 12869 MemoryRegion region(reinterpret_cast<void*>(instrs.EntryPoint()),
12859 instrs.size()); 12870 instrs.size());
12860 assembler->FinalizeInstructions(region); 12871 assembler->FinalizeInstructions(region);
12861 VerifiedMemory::Accept(region.start(), region.size()); 12872 VerifiedMemory::Accept(region.start(), region.size());
12862 CPU::FlushICache(instrs.EntryPoint(), instrs.size()); 12873 CPU::FlushICache(instrs.EntryPoint(), instrs.size());
12863 12874
12864 code.set_compile_timestamp(OS::GetCurrentTimeMicros()); 12875 code.set_compile_timestamp(OS::GetCurrentTimeMicros());
(...skipping 19 matching lines...) Expand all
12884 instrs.raw()->StorePointer(reinterpret_cast<RawObject**>(addr), 12895 instrs.raw()->StorePointer(reinterpret_cast<RawObject**>(addr),
12885 object->raw()); 12896 object->raw());
12886 } 12897 }
12887 12898
12888 // Hook up Code and Instructions objects. 12899 // Hook up Code and Instructions objects.
12889 instrs.set_code(code.raw()); 12900 instrs.set_code(code.raw());
12890 code.set_instructions(instrs.raw()); 12901 code.set_instructions(instrs.raw());
12891 code.set_is_alive(true); 12902 code.set_is_alive(true);
12892 12903
12893 // Set object pool in Instructions object. 12904 // Set object pool in Instructions object.
12894 INC_STAT(Isolate::Current(), 12905 INC_STAT(isolate,
12895 total_code_size, object_pool.Length() * sizeof(uintptr_t)); 12906 total_code_size, object_pool.Length() * sizeof(uintptr_t));
12896 instrs.set_object_pool(object_pool.raw()); 12907 instrs.set_object_pool(object_pool.raw());
12897 12908
12898 if (FLAG_write_protect_code) { 12909 if (FLAG_write_protect_code) {
12899 uword address = RawObject::ToAddr(instrs.raw()); 12910 uword address = RawObject::ToAddr(instrs.raw());
12900 bool status = VirtualMemory::Protect( 12911 bool status = VirtualMemory::Protect(
12901 reinterpret_cast<void*>(address), 12912 reinterpret_cast<void*>(address),
12902 instrs.raw()->Size(), 12913 instrs.raw()->Size(),
12903 VirtualMemory::kReadExecute); 12914 VirtualMemory::kReadExecute);
12904 ASSERT(status); 12915 ASSERT(status);
12905 } 12916 }
12906 } 12917 }
12907 code.set_comments(assembler->GetCodeComments()); 12918 code.set_comments(assembler->GetCodeComments());
12908 if (assembler->prologue_offset() >= 0) { 12919 if (assembler->prologue_offset() >= 0) {
12909 code.SetPrologueOffset(assembler->prologue_offset()); 12920 code.SetPrologueOffset(assembler->prologue_offset());
12910 } else { 12921 } else {
12911 // No prologue was ever entered, optimistically assume nothing was ever 12922 // No prologue was ever entered, optimistically assume nothing was ever
12912 // pushed onto the stack. 12923 // pushed onto the stack.
12913 code.SetPrologueOffset(assembler->CodeSize()); 12924 code.SetPrologueOffset(assembler->CodeSize());
12914 } 12925 }
12915 INC_STAT(Isolate::Current(), 12926 INC_STAT(isolate,
12916 total_code_size, code.comments().comments_.Length()); 12927 total_code_size, code.comments().comments_.Length());
12917 return code.raw(); 12928 return code.raw();
12918 } 12929 }
12919 12930
12920 12931
12921 RawCode* Code::FinalizeCode(const Function& function, 12932 RawCode* Code::FinalizeCode(const Function& function,
12922 Assembler* assembler, 12933 Assembler* assembler,
12923 bool optimized) { 12934 bool optimized) {
12924 // Calling ToLibNamePrefixedQualifiedCString is very expensive, 12935 // Calling ToLibNamePrefixedQualifiedCString is very expensive,
12925 // try to avoid it. 12936 // try to avoid it.
(...skipping 8348 matching lines...) Expand 10 before | Expand all | Expand 10 after
21274 return tag_label.ToCString(); 21285 return tag_label.ToCString();
21275 } 21286 }
21276 21287
21277 21288
21278 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 21289 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
21279 Instance::PrintJSONImpl(stream, ref); 21290 Instance::PrintJSONImpl(stream, ref);
21280 } 21291 }
21281 21292
21282 21293
21283 } // namespace dart 21294 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698