~ubuntu-branches/ubuntu/saucy/libv8/saucy

« back to all changes in this revision

Viewing changes to src/code-stubs.cc

  • Committer: Package Import Robot
  • Author(s): Jérémy Lal
  • Date: 2012-04-07 16:26:13 UTC
  • mfrom: (15.1.27 sid)
  • Revision ID: package-import@ubuntu.com-20120407162613-dqo1m6w9r3fh8tst
Tags: 3.8.9.16-3
* mipsel build fixes :
  + v8_use_mips_abi_hardfloat=false, this lowers EABI requirements.
  + v8_can_use_fpu_instructions=false, detect if FPU is present.
  + set -Wno-unused-but-set-variable only on mipsel.

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
bool CodeStub::FindCodeInCache(Code** code_out) {
41
41
  Heap* heap = Isolate::Current()->heap();
42
42
  int index = heap->code_stubs()->FindEntry(GetKey());
43
 
  if (index != NumberDictionary::kNotFound) {
 
43
  if (index != UnseededNumberDictionary::kNotFound) {
44
44
    *code_out = Code::cast(heap->code_stubs()->ValueAt(index));
45
45
    return true;
46
46
  }
101
101
  Factory* factory = isolate->factory();
102
102
  Heap* heap = isolate->heap();
103
103
  Code* code;
104
 
  if (!FindCodeInCache(&code)) {
 
104
  if (UseSpecialCache()
 
105
      ? FindCodeInSpecialCache(&code)
 
106
      : FindCodeInCache(&code)) {
 
107
    ASSERT(IsPregenerated() == code->is_pregenerated());
 
108
    return Handle<Code>(code);
 
109
  }
 
110
 
 
111
  {
105
112
    HandleScope scope(isolate);
106
113
 
107
114
    // Generate the new code.
121
128
    RecordCodeGeneration(*new_object, &masm);
122
129
    FinishCode(new_object);
123
130
 
124
 
    // Update the dictionary and the root in Heap.
125
 
    Handle<NumberDictionary> dict =
126
 
        factory->DictionaryAtNumberPut(
127
 
            Handle<NumberDictionary>(heap->code_stubs()),
128
 
            GetKey(),
129
 
            new_object);
130
 
    heap->public_set_code_stubs(*dict);
 
131
    if (UseSpecialCache()) {
 
132
      AddToSpecialCache(new_object);
 
133
    } else {
 
134
      // Update the dictionary and the root in Heap.
 
135
      Handle<UnseededNumberDictionary> dict =
 
136
          factory->DictionaryAtNumberPut(
 
137
              Handle<UnseededNumberDictionary>(heap->code_stubs()),
 
138
              GetKey(),
 
139
              new_object);
 
140
      heap->public_set_code_stubs(*dict);
 
141
    }
131
142
    code = *new_object;
132
 
    Activate(code);
133
 
  } else {
134
 
    CHECK(IsPregenerated() == code->is_pregenerated());
135
143
  }
136
144
 
 
145
  Activate(code);
137
146
  ASSERT(!NeedsImmovableCode() || heap->lo_space()->Contains(code));
138
147
  return Handle<Code>(code, isolate);
139
148
}
159
168
}
160
169
 
161
170
 
 
171
void ICCompareStub::AddToSpecialCache(Handle<Code> new_object) {
 
172
  ASSERT(*known_map_ != NULL);
 
173
  Isolate* isolate = new_object->GetIsolate();
 
174
  Factory* factory = isolate->factory();
 
175
  return Map::UpdateCodeCache(known_map_,
 
176
                              factory->compare_ic_symbol(),
 
177
                              new_object);
 
178
}
 
179
 
 
180
 
 
181
bool ICCompareStub::FindCodeInSpecialCache(Code** code_out) {
 
182
  Isolate* isolate = known_map_->GetIsolate();
 
183
  Factory* factory = isolate->factory();
 
184
  Code::Flags flags = Code::ComputeFlags(
 
185
      static_cast<Code::Kind>(GetCodeKind()),
 
186
      UNINITIALIZED);
 
187
  Handle<Object> probe(
 
188
      known_map_->FindInCodeCache(*factory->compare_ic_symbol(), flags));
 
189
  if (probe->IsCode()) {
 
190
    *code_out = Code::cast(*probe);
 
191
    return true;
 
192
  }
 
193
  return false;
 
194
}
 
195
 
 
196
 
162
197
int ICCompareStub::MinorKey() {
163
198
  return OpField::encode(op_ - Token::EQ) | StateField::encode(state_);
164
199
}
184
219
    case CompareIC::OBJECTS:
185
220
      GenerateObjects(masm);
186
221
      break;
 
222
    case CompareIC::KNOWN_OBJECTS:
 
223
      ASSERT(*known_map_ != NULL);
 
224
      GenerateKnownObjects(masm);
 
225
      break;
187
226
    default:
188
227
      UNREACHABLE();
189
228
  }