OLD | NEW |
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 <sstream> | 7 #include <sstream> |
8 | 8 |
9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
| 10 #include "src/compiler/code-stub-assembler.h" |
10 #include "src/factory.h" | 11 #include "src/factory.h" |
11 #include "src/gdb-jit.h" | 12 #include "src/gdb-jit.h" |
12 #include "src/ic/handler-compiler.h" | 13 #include "src/ic/handler-compiler.h" |
13 #include "src/ic/ic.h" | 14 #include "src/ic/ic.h" |
14 #include "src/macro-assembler.h" | 15 #include "src/macro-assembler.h" |
15 #include "src/parsing/parser.h" | 16 #include "src/parsing/parser.h" |
16 #include "src/profiler/cpu-profiler.h" | 17 #include "src/profiler/cpu-profiler.h" |
17 | 18 |
18 namespace v8 { | 19 namespace v8 { |
19 namespace internal { | 20 namespace internal { |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 UNREACHABLE(); | 335 UNREACHABLE(); |
335 return os; | 336 return os; |
336 } | 337 } |
337 | 338 |
338 | 339 |
339 void StringAddStub::PrintBaseName(std::ostream& os) const { // NOLINT | 340 void StringAddStub::PrintBaseName(std::ostream& os) const { // NOLINT |
340 os << "StringAddStub_" << flags() << "_" << pretenure_flag(); | 341 os << "StringAddStub_" << flags() << "_" << pretenure_flag(); |
341 } | 342 } |
342 | 343 |
343 | 344 |
344 void StringAddTFStub::PrintBaseName(std::ostream& os) const { // NOLINT | |
345 os << "StringAddTFStub_" << flags() << "_" << pretenure_flag(); | |
346 } | |
347 | |
348 | |
349 InlineCacheState CompareICStub::GetICState() const { | 345 InlineCacheState CompareICStub::GetICState() const { |
350 CompareICState::State state = Max(left(), right()); | 346 CompareICState::State state = Max(left(), right()); |
351 switch (state) { | 347 switch (state) { |
352 case CompareICState::UNINITIALIZED: | 348 case CompareICState::UNINITIALIZED: |
353 return ::v8::internal::UNINITIALIZED; | 349 return ::v8::internal::UNINITIALIZED; |
354 case CompareICState::BOOLEAN: | 350 case CompareICState::BOOLEAN: |
355 case CompareICState::SMI: | 351 case CompareICState::SMI: |
356 case CompareICState::NUMBER: | 352 case CompareICState::NUMBER: |
357 case CompareICState::INTERNALIZED_STRING: | 353 case CompareICState::INTERNALIZED_STRING: |
358 case CompareICState::STRING: | 354 case CompareICState::STRING: |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 state.RemoveAll(); | 462 state.RemoveAll(); |
467 state.Add(GENERIC); | 463 state.Add(GENERIC); |
468 } else { | 464 } else { |
469 state.Add(MONOMORPHIC_MAP); | 465 state.Add(MONOMORPHIC_MAP); |
470 } | 466 } |
471 TraceTransition(old_state, state); | 467 TraceTransition(old_state, state); |
472 set_sub_minor_key(TypesBits::update(sub_minor_key(), state.ToIntegral())); | 468 set_sub_minor_key(TypesBits::update(sub_minor_key(), state.ToIntegral())); |
473 } | 469 } |
474 | 470 |
475 | 471 |
476 namespace { | |
477 | |
478 Handle<JSFunction> GetFunction(Isolate* isolate, const char* name) { | |
479 v8::ExtensionConfiguration no_extensions; | |
480 MaybeHandle<Object> fun = Object::GetProperty( | |
481 isolate, isolate->factory()->code_stub_exports_object(), name); | |
482 Handle<JSFunction> function = Handle<JSFunction>::cast(fun.ToHandleChecked()); | |
483 DCHECK(!function->IsUndefined() && | |
484 "JavaScript implementation of stub not found"); | |
485 return function; | |
486 } | |
487 } // namespace | |
488 | |
489 | |
490 Handle<Code> TurboFanCodeStub::GenerateCode() { | 472 Handle<Code> TurboFanCodeStub::GenerateCode() { |
491 // Get the outer ("stub generator") function. | |
492 const char* name = CodeStub::MajorName(MajorKey()); | 473 const char* name = CodeStub::MajorName(MajorKey()); |
493 Handle<JSFunction> outer = GetFunction(isolate(), name); | 474 Zone zone; |
494 DCHECK_EQ(2, outer->shared()->length()); | 475 CallInterfaceDescriptor descriptor(GetCallInterfaceDescriptor()); |
495 | 476 compiler::CodeStubAssembler assembler(isolate(), &zone, descriptor, |
496 // Invoke the outer function to get the stub itself. | 477 GetCodeKind(), name); |
497 Factory* factory = isolate()->factory(); | 478 GenerateAssembly(&assembler); |
498 Handle<Object> call_conv = factory->InternalizeUtf8String(name); | 479 return assembler.GenerateCode(); |
499 Handle<Object> minor_key = factory->NewNumber(MinorKey()); | |
500 Handle<Object> args[] = {call_conv, minor_key}; | |
501 MaybeHandle<Object> result = | |
502 Execution::Call(isolate(), outer, factory->undefined_value(), 2, args); | |
503 Handle<JSFunction> inner = Handle<JSFunction>::cast(result.ToHandleChecked()); | |
504 // Just to make sure nobody calls this... | |
505 inner->set_code(isolate()->builtins()->builtin(Builtins::kIllegal)); | |
506 | |
507 return Compiler::GetStubCode(inner, this).ToHandleChecked(); | |
508 } | 480 } |
509 | 481 |
510 | 482 |
| 483 void StringLengthStub::GenerateAssembly( |
| 484 compiler::CodeStubAssembler* assembler) const { |
| 485 compiler::Node* value = assembler->Parameter(0); |
| 486 compiler::Node* string = |
| 487 assembler->LoadObjectField(value, JSValue::kValueOffset); |
| 488 compiler::Node* result = |
| 489 assembler->LoadObjectField(string, String::kLengthOffset); |
| 490 assembler->Return(result); |
| 491 } |
| 492 |
| 493 |
511 template<class StateType> | 494 template<class StateType> |
512 void HydrogenCodeStub::TraceTransition(StateType from, StateType to) { | 495 void HydrogenCodeStub::TraceTransition(StateType from, StateType to) { |
513 // Note: Although a no-op transition is semantically OK, it is hinting at a | 496 // Note: Although a no-op transition is semantically OK, it is hinting at a |
514 // bug somewhere in our state transition machinery. | 497 // bug somewhere in our state transition machinery. |
515 DCHECK(from != to); | 498 DCHECK(from != to); |
516 if (!FLAG_trace_ic) return; | 499 if (!FLAG_trace_ic) return; |
517 OFStream os(stdout); | 500 OFStream os(stdout); |
518 os << "["; | 501 os << "["; |
519 PrintBaseName(os); | 502 PrintBaseName(os); |
520 os << ": " << from << "=>" << to << "]" << std::endl; | 503 os << ": " << from << "=>" << to << "]" << std::endl; |
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1061 if (type->Is(Type::UntaggedPointer())) { | 1044 if (type->Is(Type::UntaggedPointer())) { |
1062 return Representation::External(); | 1045 return Representation::External(); |
1063 } | 1046 } |
1064 | 1047 |
1065 DCHECK(!type->Is(Type::Untagged())); | 1048 DCHECK(!type->Is(Type::Untagged())); |
1066 return Representation::Tagged(); | 1049 return Representation::Tagged(); |
1067 } | 1050 } |
1068 | 1051 |
1069 } // namespace internal | 1052 } // namespace internal |
1070 } // namespace v8 | 1053 } // namespace v8 |
OLD | NEW |