OLD | NEW |
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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 } | 184 } |
185 | 185 |
186 virtual HValue* BuildCodeInitializedStub() { | 186 virtual HValue* BuildCodeInitializedStub() { |
187 UNIMPLEMENTED(); | 187 UNIMPLEMENTED(); |
188 return NULL; | 188 return NULL; |
189 } | 189 } |
190 | 190 |
191 virtual HValue* BuildCodeUninitializedStub() { | 191 virtual HValue* BuildCodeUninitializedStub() { |
192 // Force a deopt that falls back to the runtime. | 192 // Force a deopt that falls back to the runtime. |
193 HValue* undefined = graph()->GetConstantUndefined(); | 193 HValue* undefined = graph()->GetConstantUndefined(); |
194 CheckBuilder builder(this); | 194 IfBuilder builder(this); |
195 builder.CheckNotUndefined(undefined); | 195 builder.IfNot<HCompareObjectEqAndBranch, HValue*>(undefined, undefined); |
196 builder.End(); | 196 builder.Then(); |
| 197 builder.ElseDeopt(); |
197 return undefined; | 198 return undefined; |
198 } | 199 } |
199 | 200 |
200 Stub* casted_stub() { return static_cast<Stub*>(stub()); } | 201 Stub* casted_stub() { return static_cast<Stub*>(stub()); } |
201 }; | 202 }; |
202 | 203 |
203 | 204 |
204 Handle<Code> HydrogenCodeStub::GenerateLightweightMissCode(Isolate* isolate) { | 205 Handle<Code> HydrogenCodeStub::GenerateLightweightMissCode(Isolate* isolate) { |
205 Factory* factory = isolate->factory(); | 206 Factory* factory = isolate->factory(); |
206 | 207 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 LChunk* chunk = OptimizeGraph(builder.CreateGraph()); | 257 LChunk* chunk = OptimizeGraph(builder.CreateGraph()); |
257 return chunk->Codegen(); | 258 return chunk->Codegen(); |
258 } | 259 } |
259 } | 260 } |
260 | 261 |
261 | 262 |
262 template <> | 263 template <> |
263 HValue* CodeStubGraphBuilder<FastCloneShallowArrayStub>::BuildCodeStub() { | 264 HValue* CodeStubGraphBuilder<FastCloneShallowArrayStub>::BuildCodeStub() { |
264 Zone* zone = this->zone(); | 265 Zone* zone = this->zone(); |
265 Factory* factory = isolate()->factory(); | 266 Factory* factory = isolate()->factory(); |
| 267 HValue* undefined = graph()->GetConstantUndefined(); |
266 AllocationSiteMode alloc_site_mode = casted_stub()->allocation_site_mode(); | 268 AllocationSiteMode alloc_site_mode = casted_stub()->allocation_site_mode(); |
267 FastCloneShallowArrayStub::Mode mode = casted_stub()->mode(); | 269 FastCloneShallowArrayStub::Mode mode = casted_stub()->mode(); |
268 int length = casted_stub()->length(); | 270 int length = casted_stub()->length(); |
269 | 271 |
270 HInstruction* boilerplate = | 272 HInstruction* boilerplate = |
271 AddInstruction(new(zone) HLoadKeyed(GetParameter(0), | 273 AddInstruction(new(zone) HLoadKeyed(GetParameter(0), |
272 GetParameter(1), | 274 GetParameter(1), |
273 NULL, | 275 NULL, |
274 FAST_ELEMENTS)); | 276 FAST_ELEMENTS)); |
275 | 277 |
276 CheckBuilder builder(this); | 278 IfBuilder checker(this); |
277 builder.CheckNotUndefined(boilerplate); | 279 checker.IfNot<HCompareObjectEqAndBranch, HValue*>(boilerplate, undefined); |
| 280 checker.Then(); |
278 | 281 |
279 if (mode == FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS) { | 282 if (mode == FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS) { |
280 HValue* elements = | 283 HValue* elements = |
281 AddInstruction(new(zone) HLoadElements(boilerplate, NULL)); | 284 AddInstruction(new(zone) HLoadElements(boilerplate, NULL)); |
282 | 285 |
283 IfBuilder if_fixed_cow(this); | 286 IfBuilder if_fixed_cow(this); |
284 if_fixed_cow.IfCompareMap(elements, factory->fixed_cow_array_map()); | 287 if_fixed_cow.IfCompareMap(elements, factory->fixed_cow_array_map()); |
285 if_fixed_cow.Then(); | 288 if_fixed_cow.Then(); |
286 environment()->Push(BuildCloneShallowArray(context(), | 289 environment()->Push(BuildCloneShallowArray(context(), |
287 boilerplate, | 290 boilerplate, |
(...skipping 18 matching lines...) Expand all Loading... |
306 length)); | 309 length)); |
307 } else { | 310 } else { |
308 ElementsKind elements_kind = casted_stub()->ComputeElementsKind(); | 311 ElementsKind elements_kind = casted_stub()->ComputeElementsKind(); |
309 environment()->Push(BuildCloneShallowArray(context(), | 312 environment()->Push(BuildCloneShallowArray(context(), |
310 boilerplate, | 313 boilerplate, |
311 alloc_site_mode, | 314 alloc_site_mode, |
312 elements_kind, | 315 elements_kind, |
313 length)); | 316 length)); |
314 } | 317 } |
315 | 318 |
316 return environment()->Pop(); | 319 HValue* result = environment()->Pop(); |
| 320 checker.ElseDeopt(); |
| 321 return result; |
317 } | 322 } |
318 | 323 |
319 | 324 |
320 Handle<Code> FastCloneShallowArrayStub::GenerateCode() { | 325 Handle<Code> FastCloneShallowArrayStub::GenerateCode() { |
321 return DoGenerateCode(this); | 326 return DoGenerateCode(this); |
322 } | 327 } |
323 | 328 |
324 | 329 |
325 template <> | 330 template <> |
326 HValue* CodeStubGraphBuilder<FastCloneShallowObjectStub>::BuildCodeStub() { | 331 HValue* CodeStubGraphBuilder<FastCloneShallowObjectStub>::BuildCodeStub() { |
327 Zone* zone = this->zone(); | 332 Zone* zone = this->zone(); |
328 Factory* factory = isolate()->factory(); | 333 Factory* factory = isolate()->factory(); |
| 334 HValue* undefined = graph()->GetConstantUndefined(); |
329 | 335 |
330 HInstruction* boilerplate = | 336 HInstruction* boilerplate = |
331 AddInstruction(new(zone) HLoadKeyed(GetParameter(0), | 337 AddInstruction(new(zone) HLoadKeyed(GetParameter(0), |
332 GetParameter(1), | 338 GetParameter(1), |
333 NULL, | 339 NULL, |
334 FAST_ELEMENTS)); | 340 FAST_ELEMENTS)); |
335 | 341 |
336 CheckBuilder builder(this); | 342 IfBuilder checker(this); |
337 builder.CheckNotUndefined(boilerplate); | 343 checker.IfNot<HCompareObjectEqAndBranch, HValue*>(boilerplate, undefined); |
| 344 checker.And(); |
338 | 345 |
339 int size = JSObject::kHeaderSize + casted_stub()->length() * kPointerSize; | 346 int size = JSObject::kHeaderSize + casted_stub()->length() * kPointerSize; |
340 HValue* boilerplate_size = | 347 HValue* boilerplate_size = |
341 AddInstruction(new(zone) HInstanceSize(boilerplate)); | 348 AddInstruction(new(zone) HInstanceSize(boilerplate)); |
342 HValue* size_in_words = | 349 HValue* size_in_words = |
343 AddInstruction(new(zone) HConstant(size >> kPointerSizeLog2, | 350 AddInstruction(new(zone) HConstant(size >> kPointerSizeLog2, |
344 Representation::Integer32())); | 351 Representation::Integer32())); |
345 builder.CheckIntegerEq(boilerplate_size, size_in_words); | 352 checker.IfCompare(boilerplate_size, size_in_words, Token::EQ); |
| 353 checker.Then(); |
346 | 354 |
347 HValue* size_in_bytes = | 355 HValue* size_in_bytes = |
348 AddInstruction(new(zone) HConstant(size, Representation::Integer32())); | 356 AddInstruction(new(zone) HConstant(size, Representation::Integer32())); |
349 HAllocate::Flags flags = HAllocate::CAN_ALLOCATE_IN_NEW_SPACE; | 357 HAllocate::Flags flags = HAllocate::CAN_ALLOCATE_IN_NEW_SPACE; |
350 if (FLAG_pretenure_literals) { | 358 if (FLAG_pretenure_literals) { |
351 flags = static_cast<HAllocate::Flags>( | 359 flags = static_cast<HAllocate::Flags>( |
352 flags | HAllocate::CAN_ALLOCATE_IN_OLD_POINTER_SPACE); | 360 flags | HAllocate::CAN_ALLOCATE_IN_OLD_POINTER_SPACE); |
353 } | 361 } |
354 HInstruction* object = | 362 HInstruction* object = |
355 AddInstruction(new(zone) HAllocate(context(), | 363 AddInstruction(new(zone) HAllocate(context(), |
356 size_in_bytes, | 364 size_in_bytes, |
357 HType::JSObject(), | 365 HType::JSObject(), |
358 flags)); | 366 flags)); |
359 | 367 |
360 for (int i = 0; i < size; i += kPointerSize) { | 368 for (int i = 0; i < size; i += kPointerSize) { |
361 HInstruction* value = | 369 HInstruction* value = |
362 AddInstruction(new(zone) HLoadNamedField(boilerplate, true, i)); | 370 AddInstruction(new(zone) HLoadNamedField(boilerplate, true, i)); |
363 AddInstruction(new(zone) HStoreNamedField(object, | 371 AddInstruction(new(zone) HStoreNamedField(object, |
364 factory->empty_string(), | 372 factory->empty_string(), |
365 value, | 373 value, |
366 true, i)); | 374 true, i)); |
367 } | 375 } |
368 | 376 |
369 builder.End(); | 377 checker.ElseDeopt(); |
370 return object; | 378 return object; |
371 } | 379 } |
372 | 380 |
373 | 381 |
374 Handle<Code> FastCloneShallowObjectStub::GenerateCode() { | 382 Handle<Code> FastCloneShallowObjectStub::GenerateCode() { |
375 return DoGenerateCode(this); | 383 return DoGenerateCode(this); |
376 } | 384 } |
377 | 385 |
378 | 386 |
379 template <> | 387 template <> |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 current_block()->MarkAsDeoptimizing(); | 511 current_block()->MarkAsDeoptimizing(); |
504 return GetParameter(0); | 512 return GetParameter(0); |
505 } | 513 } |
506 | 514 |
507 | 515 |
508 Handle<Code> ArrayNArgumentsConstructorStub::GenerateCode() { | 516 Handle<Code> ArrayNArgumentsConstructorStub::GenerateCode() { |
509 return DoGenerateCode(this); | 517 return DoGenerateCode(this); |
510 } | 518 } |
511 | 519 |
512 } } // namespace v8::internal | 520 } } // namespace v8::internal |
OLD | NEW |