builtins-handler-gen.cc 3.94 KB
Newer Older
1 2 3 4
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5
#include "src/builtins/builtins-utils-gen.h"
6
#include "src/builtins/builtins.h"
7
#include "src/code-stub-assembler.h"
8
#include "src/ic/ic.h"
9
#include "src/ic/keyed-store-generic.h"
10
#include "src/objects-inl.h"
11 12 13 14

namespace v8 {
namespace internal {

15
TF_BUILTIN(LoadIC_StringLength, CodeStubAssembler) {
16 17 18 19 20
  Node* string = Parameter(Descriptor::kReceiver);
  Return(LoadStringLengthAsSmi(string));
}

TF_BUILTIN(LoadIC_StringWrapperLength, CodeStubAssembler) {
21 22
  Node* value = Parameter(Descriptor::kReceiver);
  Node* string = LoadJSValueValue(value);
23
  Return(LoadStringLengthAsSmi(string));
24 25
}

26 27 28 29
TF_BUILTIN(KeyedLoadIC_Slow, CodeStubAssembler) {
  Node* receiver = Parameter(Descriptor::kReceiver);
  Node* name = Parameter(Descriptor::kName);
  Node* context = Parameter(Descriptor::kContext);
30

31
  TailCallRuntime(Runtime::kKeyedGetProperty, context, receiver, name);
32 33
}

34
void Builtins::Generate_KeyedStoreIC_Megamorphic(
35
    compiler::CodeAssemblerState* state) {
36
  KeyedStoreGenericGenerator::Generate(state);
37 38
}

39 40
void Builtins::Generate_StoreIC_Uninitialized(
    compiler::CodeAssemblerState* state) {
41
  StoreICUninitializedGenerator::Generate(state);
42 43
}

44 45 46 47 48 49 50 51 52 53 54 55
TF_BUILTIN(KeyedStoreIC_Slow, CodeStubAssembler) {
  Node* receiver = Parameter(Descriptor::kReceiver);
  Node* name = Parameter(Descriptor::kName);
  Node* value = Parameter(Descriptor::kValue);
  Node* slot = Parameter(Descriptor::kSlot);
  Node* vector = Parameter(Descriptor::kVector);
  Node* context = Parameter(Descriptor::kContext);

  // The slow case calls into the runtime to complete the store without causing
  // an IC miss that would otherwise cause a transition to the generic stub.
  TailCallRuntime(Runtime::kKeyedStoreIC_Slow, context, value, slot, vector,
                  receiver, name);
56 57
}

58 59 60 61 62 63 64 65 66
TF_BUILTIN(StoreInArrayLiteralIC_Slow, CodeStubAssembler) {
  Node* array = Parameter(Descriptor::kReceiver);
  Node* index = Parameter(Descriptor::kName);
  Node* value = Parameter(Descriptor::kValue);
  Node* context = Parameter(Descriptor::kContext);
  TailCallRuntime(Runtime::kStoreInArrayLiteralIC_Slow, context, value, array,
                  index);
}

67 68
TF_BUILTIN(LoadGlobalIC_Slow, CodeStubAssembler) {
  Node* name = Parameter(Descriptor::kName);
69 70
  Node* slot = Parameter(Descriptor::kSlot);
  Node* vector = Parameter(Descriptor::kVector);
71
  Node* context = Parameter(Descriptor::kContext);
72

73
  TailCallRuntime(Runtime::kLoadGlobalIC_Slow, context, name, slot, vector);
74 75
}

76 77 78 79 80 81 82
TF_BUILTIN(LoadIC_FunctionPrototype, CodeStubAssembler) {
  Node* receiver = Parameter(Descriptor::kReceiver);
  Node* name = Parameter(Descriptor::kName);
  Node* slot = Parameter(Descriptor::kSlot);
  Node* vector = Parameter(Descriptor::kVector);
  Node* context = Parameter(Descriptor::kContext);

83 84
  Label miss(this, Label::kDeferred);
  Return(LoadJSFunctionPrototype(receiver, &miss));
85

86
  BIND(&miss);
87 88 89
  TailCallRuntime(Runtime::kLoadIC_Miss, context, receiver, name, slot, vector);
}

90 91 92 93
TF_BUILTIN(LoadIC_Slow, CodeStubAssembler) {
  Node* receiver = Parameter(Descriptor::kReceiver);
  Node* name = Parameter(Descriptor::kName);
  Node* context = Parameter(Descriptor::kContext);
94

95
  TailCallRuntime(Runtime::kGetProperty, context, receiver, name);
96 97
}

98 99 100 101 102 103 104 105 106 107 108 109 110 111
TF_BUILTIN(StoreGlobalIC_Slow, CodeStubAssembler) {
  Node* receiver = Parameter(Descriptor::kReceiver);
  Node* name = Parameter(Descriptor::kName);
  Node* value = Parameter(Descriptor::kValue);
  Node* slot = Parameter(Descriptor::kSlot);
  Node* vector = Parameter(Descriptor::kVector);
  Node* context = Parameter(Descriptor::kContext);

  // The slow case calls into the runtime to complete the store without causing
  // an IC miss that would otherwise cause a transition to the generic stub.
  TailCallRuntime(Runtime::kStoreGlobalIC_Slow, context, value, slot, vector,
                  receiver, name);
}

112 113
}  // namespace internal
}  // namespace v8