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

Side by Side Diff: src/hydrogen.cc

Issue 12521011: Compile FastCloneShallowArrayStub using Crankshaft. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Make this thing work with snapshots. Created 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 input_representation); 711 input_representation);
712 compare->ChangeRepresentation(input_representation); 712 compare->ChangeRepresentation(input_representation);
713 compare->SetSuccessorAt(0, first_true_block_); 713 compare->SetSuccessorAt(0, first_true_block_);
714 compare->SetSuccessorAt(1, first_false_block_); 714 compare->SetSuccessorAt(1, first_false_block_);
715 builder_->current_block()->Finish(compare); 715 builder_->current_block()->Finish(compare);
716 builder_->set_current_block(first_true_block_); 716 builder_->set_current_block(first_true_block_);
717 return compare; 717 return compare;
718 } 718 }
719 719
720 720
721 void HGraphBuilder::IfBuilder::BeginCompareMapTrue(HValue* val,
722 Handle<Map> map) {
723 HCompareMap* compare =
724 new(zone()) HCompareMap(val, map, first_true_block_, first_false_block_);
725 builder_->current_block()->Finish(compare);
726 builder_->set_current_block(first_true_block_);
727 }
728
729
721 void HGraphBuilder::IfBuilder::BeginFalse() { 730 void HGraphBuilder::IfBuilder::BeginFalse() {
722 last_true_block_ = builder_->current_block(); 731 last_true_block_ = builder_->current_block();
723 ASSERT(!last_true_block_->IsFinished()); 732 ASSERT(!last_true_block_->IsFinished());
724 builder_->set_current_block(first_false_block_); 733 builder_->set_current_block(first_false_block_);
725 } 734 }
726 735
727 736
728 void HGraphBuilder::IfBuilder::End() { 737 void HGraphBuilder::IfBuilder::End() {
729 ASSERT(!finished_); 738 ASSERT(!finished_);
730 ASSERT(!last_true_block_->IsFinished()); 739 ASSERT(!last_true_block_->IsFinished());
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
1145 ALLOW_RETURN_HOLE)); 1154 ALLOW_RETURN_HOLE));
1146 1155
1147 AddInstruction(new(zone()) HStoreKeyed(to_elements, key, element, 1156 AddInstruction(new(zone()) HStoreKeyed(to_elements, key, element,
1148 to_elements_kind)); 1157 to_elements_kind));
1149 AddSimulate(BailoutId::StubEntry(), REMOVABLE_SIMULATE); 1158 AddSimulate(BailoutId::StubEntry(), REMOVABLE_SIMULATE);
1150 1159
1151 builder.EndBody(); 1160 builder.EndBody();
1152 } 1161 }
1153 1162
1154 1163
1164 HValue* HGraphBuilder::BuildCloneShallowArray(HContext* context,
1165 HValue* boilerplate,
1166 AllocationSiteMode mode,
1167 ElementsKind kind,
1168 BailoutId id,
1169 int length) {
1170 Zone* zone = this->zone();
1171 Factory* factory = isolate()->factory();
1172
1173 // All sizes here are multiples of kPointerSize.
1174 int size = JSArray::kSize;
1175 if (mode == TRACK_ALLOCATION_SITE) {
1176 size += AllocationSiteInfo::kSize;
1177 }
1178 int elems_offset = size;
1179 if (length > 0) {
1180 size += IsFastDoubleElementsKind(kind)
1181 ? FixedDoubleArray::SizeFor(length)
1182 : FixedArray::SizeFor(length);
1183 }
1184
1185 HAllocate::Flags allocate_flags = HAllocate::CAN_ALLOCATE_IN_NEW_SPACE;
1186 if (IsFastDoubleElementsKind(kind)) {
1187 allocate_flags = static_cast<HAllocate::Flags>(
1188 allocate_flags | HAllocate::ALLOCATE_DOUBLE_ALIGNED);
1189 }
1190
1191 // Allocate both the JS array and the elements array in one big
1192 // allocation. This avoids multiple limit checks.
1193 HValue* size_in_bytes =
1194 AddInstruction(new(zone) HConstant(size, Representation::Integer32()));
1195 HInstruction* object =
1196 AddInstruction(new(zone) HAllocate(context,
1197 size_in_bytes,
1198 HType::JSObject(),
1199 allocate_flags));
1200
1201 // Copy the JS array part.
1202 for (int i = 0; i < JSArray::kSize; i += kPointerSize) {
1203 if ((i != JSArray::kElementsOffset) || (length == 0)) {
1204 HInstruction* value =
1205 AddInstruction(new(zone) HLoadNamedField(boilerplate, true, i));
danno 2013/04/04 11:16:56 You need to use BuildStoreMap for the map (skip th
Michael Starzinger 2013/04/04 17:07:02 Done.
1206 AddInstruction(new(zone) HStoreNamedField(object,
1207 factory->empty_string(),
1208 value,
1209 true, i));
1210 AddSimulate(id);
1211 }
1212 }
1213
1214 // Create an allocation site info if requested.
1215 if (mode == TRACK_ALLOCATION_SITE) {
1216 HValue* alloc_site =
1217 AddInstruction(new(zone) HInnerAllocatedObject(object, JSArray::kSize));
1218 Handle<Map> alloc_site_map(isolate()->heap()->allocation_site_info_map());
1219 BuildStoreMap(alloc_site, alloc_site_map, id);
1220 int alloc_payload_offset = AllocationSiteInfo::kPayloadOffset;
1221 AddInstruction(new(zone) HStoreNamedField(alloc_site,
1222 factory->empty_string(),
1223 boilerplate,
1224 true, alloc_payload_offset));
1225 AddSimulate(id);
1226 }
1227
1228 if (length > 0) {
1229 // Get hold of the elements array of the boilerplate and setup the
1230 // elements pointer in the resulting object.
1231 HValue* boilerplate_elements =
1232 AddInstruction(new(zone) HLoadElements(boilerplate, NULL));
1233 HValue* object_elements =
1234 AddInstruction(new(zone) HInnerAllocatedObject(object, elems_offset));
1235 AddInstruction(new(zone) HStoreNamedField(object,
1236 factory->elements_field_string(),
1237 object_elements,
1238 true, JSObject::kElementsOffset));
1239 AddSimulate(id);
1240
1241 // Copy the elements array header.
1242 for (int i = 0; i < FixedArrayBase::kHeaderSize; i += kPointerSize) {
1243 HInstruction* value =
1244 AddInstruction(new(zone) HLoadNamedField(boilerplate_elements,
1245 true, i));
1246 AddInstruction(new(zone) HStoreNamedField(object_elements,
1247 factory->empty_string(),
1248 value,
1249 true, i));
1250 AddSimulate(id);
1251 }
1252
1253 // Copy the elements array contents.
1254 for (int i = 0; i < length; i++) {
danno 2013/04/04 11:16:56 Can you use HGraphBuilder::BuildCopyElements here?
Michael Starzinger 2013/04/04 17:07:02 As discussed offline: Yes, nice idea. We should te
1255 HValue* key_constant =
1256 AddInstruction(new(zone) HConstant(i, Representation::Integer32()));
1257 HInstruction* value =
1258 AddInstruction(new(zone) HLoadKeyed(boilerplate_elements,
1259 key_constant,
1260 NULL,
1261 kind));
1262 AddInstruction(new(zone) HStoreKeyed(object_elements,
1263 key_constant,
1264 value,
1265 kind));
1266 AddSimulate(id);
1267 }
1268 }
1269
1270 return object;
1271 }
1272
1273
1155 HOptimizedGraphBuilder::HOptimizedGraphBuilder(CompilationInfo* info, 1274 HOptimizedGraphBuilder::HOptimizedGraphBuilder(CompilationInfo* info,
1156 TypeFeedbackOracle* oracle) 1275 TypeFeedbackOracle* oracle)
1157 : HGraphBuilder(info), 1276 : HGraphBuilder(info),
1158 function_state_(NULL), 1277 function_state_(NULL),
1159 initial_function_state_(this, info, oracle, NORMAL_RETURN), 1278 initial_function_state_(this, info, oracle, NORMAL_RETURN),
1160 ast_context_(NULL), 1279 ast_context_(NULL),
1161 break_scope_(NULL), 1280 break_scope_(NULL),
1162 inlined_count_(0), 1281 inlined_count_(0),
1163 globals_(10, info->zone()), 1282 globals_(10, info->zone()),
1164 inline_bailout_(false) { 1283 inline_bailout_(false) {
(...skipping 9763 matching lines...) Expand 10 before | Expand all | Expand 10 after
10928 } 11047 }
10929 } 11048 }
10930 11049
10931 #ifdef DEBUG 11050 #ifdef DEBUG
10932 if (graph_ != NULL) graph_->Verify(false); // No full verify. 11051 if (graph_ != NULL) graph_->Verify(false); // No full verify.
10933 if (allocator_ != NULL) allocator_->Verify(); 11052 if (allocator_ != NULL) allocator_->Verify();
10934 #endif 11053 #endif
10935 } 11054 }
10936 11055
10937 } } // namespace v8::internal 11056 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen.h ('k') | src/ia32/code-stubs-ia32.cc » ('j') | src/isolate.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698