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

Side by Side Diff: src/code-stubs-hydrogen.cc

Issue 1475823003: [runtime] First step to sanitize regexp literal creation. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years 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 | « src/code-stubs.cc ('k') | src/compiler/ast-graph-builder.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/code-stubs.h" 5 #include "src/code-stubs.h"
6 6
7 #include "src/bailout-reason.h" 7 #include "src/bailout-reason.h"
8 #include "src/crankshaft/hydrogen.h" 8 #include "src/crankshaft/hydrogen.h"
9 #include "src/crankshaft/lithium.h" 9 #include "src/crankshaft/lithium.h"
10 #include "src/field-index.h" 10 #include "src/field-index.h"
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 is_smi.End(); 426 is_smi.End();
427 427
428 return environment()->Pop(); 428 return environment()->Pop();
429 } 429 }
430 430
431 431
432 Handle<Code> TypeofStub::GenerateCode() { return DoGenerateCode(this); } 432 Handle<Code> TypeofStub::GenerateCode() { return DoGenerateCode(this); }
433 433
434 434
435 template <> 435 template <>
436 HValue* CodeStubGraphBuilder<FastCloneRegExpStub>::BuildCodeStub() {
437 HValue* closure = GetParameter(0);
438 HValue* literal_index = GetParameter(1);
439
440 // This stub is very performance sensitive, the generated code must be tuned
441 // so that it doesn't build and eager frame.
Yang 2015/11/25 09:06:10 Haha! Found typo "build an eager frame" :)
442 info()->MarkMustNotHaveEagerFrame();
443
444 HValue* literals_array = Add<HLoadNamedField>(
445 closure, nullptr, HObjectAccess::ForLiteralsPointer());
446 HInstruction* boilerplate = Add<HLoadKeyed>(
447 literals_array, literal_index, nullptr, FAST_ELEMENTS, NEVER_RETURN_HOLE,
448 LiteralsArray::kOffsetToFirstLiteral - kHeapObjectTag);
449
450 IfBuilder if_notundefined(this);
451 if_notundefined.IfNot<HCompareObjectEqAndBranch>(
452 boilerplate, graph()->GetConstantUndefined());
453 if_notundefined.Then();
454 {
455 int result_size =
456 JSRegExp::kSize + JSRegExp::kInObjectFieldCount * kPointerSize;
457 HValue* result =
458 Add<HAllocate>(Add<HConstant>(result_size), HType::JSObject(),
459 NOT_TENURED, JS_REGEXP_TYPE);
460 Add<HStoreNamedField>(
461 result, HObjectAccess::ForMap(),
462 Add<HLoadNamedField>(boilerplate, nullptr, HObjectAccess::ForMap()));
463 Add<HStoreNamedField>(
464 result, HObjectAccess::ForPropertiesPointer(),
465 Add<HLoadNamedField>(boilerplate, nullptr,
466 HObjectAccess::ForPropertiesPointer()));
467 Add<HStoreNamedField>(
468 result, HObjectAccess::ForElementsPointer(),
469 Add<HLoadNamedField>(boilerplate, nullptr,
470 HObjectAccess::ForElementsPointer()));
471 for (int offset = JSObject::kHeaderSize; offset < result_size;
472 offset += kPointerSize) {
473 HObjectAccess access = HObjectAccess::ForObservableJSObjectOffset(offset);
474 Add<HStoreNamedField>(result, access,
475 Add<HLoadNamedField>(boilerplate, nullptr, access));
476 }
477 Push(result);
478 }
479 if_notundefined.ElseDeopt(Deoptimizer::kUninitializedBoilerplateInFastClone);
480 if_notundefined.End();
481
482 return Pop();
483 }
484
485
486 Handle<Code> FastCloneRegExpStub::GenerateCode() {
487 return DoGenerateCode(this);
488 }
489
490
491 template <>
436 HValue* CodeStubGraphBuilder<FastCloneShallowArrayStub>::BuildCodeStub() { 492 HValue* CodeStubGraphBuilder<FastCloneShallowArrayStub>::BuildCodeStub() {
437 Factory* factory = isolate()->factory(); 493 Factory* factory = isolate()->factory();
438 HValue* undefined = graph()->GetConstantUndefined(); 494 HValue* undefined = graph()->GetConstantUndefined();
439 AllocationSiteMode alloc_site_mode = casted_stub()->allocation_site_mode(); 495 AllocationSiteMode alloc_site_mode = casted_stub()->allocation_site_mode();
440 HValue* closure = GetParameter(0); 496 HValue* closure = GetParameter(0);
441 HValue* literal_index = GetParameter(1); 497 HValue* literal_index = GetParameter(1);
442 498
443 // This stub is very performance sensitive, the generated code must be tuned 499 // This stub is very performance sensitive, the generated code must be tuned
444 // so that it doesn't build and eager frame. 500 // so that it doesn't build and eager frame.
445 info()->MarkMustNotHaveEagerFrame(); 501 info()->MarkMustNotHaveEagerFrame();
(...skipping 1943 matching lines...) Expand 10 before | Expand all | Expand 10 after
2389 return Pop(); 2445 return Pop();
2390 } 2446 }
2391 2447
2392 2448
2393 Handle<Code> KeyedLoadGenericStub::GenerateCode() { 2449 Handle<Code> KeyedLoadGenericStub::GenerateCode() {
2394 return DoGenerateCode(this); 2450 return DoGenerateCode(this);
2395 } 2451 }
2396 2452
2397 } // namespace internal 2453 } // namespace internal
2398 } // namespace v8 2454 } // namespace v8
OLDNEW
« no previous file with comments | « src/code-stubs.cc ('k') | src/compiler/ast-graph-builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698