Commit 667f15a1 authored by yangguo@chromium.org's avatar yangguo@chromium.org

Fix serializing ICs.

R=mvstanton@chromium.org

Review URL: https://codereview.chromium.org/587213002

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@24262 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 3ef16353
......@@ -1562,7 +1562,7 @@ void Builtins::SetUp(Isolate* isolate, bool create_heap_objects) {
// Move the code into the object heap.
CodeDesc desc;
masm.GetCode(&desc);
Code::Flags flags = functions[i].flags;
Code::Flags flags = functions[i].flags;
Handle<Code> code =
isolate->factory()->NewCode(desc, flags, masm.CodeObject());
// Log the event and add the code to the builtins array.
......
......@@ -136,10 +136,12 @@ namespace internal {
class CodeStub BASE_EMBEDDED {
public:
enum Major {
// TODO(mvstanton): eliminate the NoCache key by getting rid
// of the non-monomorphic-cache.
NoCache = 0, // marker for stubs that do custom caching]
#define DEF_ENUM(name) name,
CODE_STUB_LIST(DEF_ENUM)
#undef DEF_ENUM
NoCache, // marker for stubs that do custom caching
NUMBER_OF_IDS
};
......
......@@ -1894,15 +1894,26 @@ void CodeSerializer::SerializeObject(Object* o, HowToCode how_to_code,
if (heap_object->IsCode()) {
Code* code_object = Code::cast(heap_object);
DCHECK(!code_object->is_optimized_code());
if (code_object->kind() == Code::BUILTIN) {
SerializeBuiltin(code_object, how_to_code, where_to_point, skip);
return;
} else if (code_object->IsCodeStubOrIC()) {
SerializeCodeStub(code_object, how_to_code, where_to_point, skip);
return;
switch (code_object->kind()) {
case Code::OPTIMIZED_FUNCTION: // No optimized code compiled yet.
case Code::HANDLER: // No handlers patched in yet.
case Code::REGEXP: // No regexp literals initialized yet.
case Code::NUMBER_OF_KINDS: // Pseudo enum value.
CHECK(false);
case Code::BUILTIN:
SerializeBuiltin(code_object, how_to_code, where_to_point, skip);
return;
case Code::STUB:
SerializeCodeStub(code_object, how_to_code, where_to_point, skip);
return;
#define IC_KIND_CASE(KIND) case Code::KIND:
IC_KIND_LIST(IC_KIND_CASE)
#undef IC_KIND_CASE
// TODO(yangguo): add special handling to canonicalize ICs.
case Code::FUNCTION:
SerializeHeapObject(code_object, how_to_code, where_to_point, skip);
return;
}
code_object->ClearInlineCaches();
}
if (heap_object == source_) {
......@@ -1967,20 +1978,13 @@ void CodeSerializer::SerializeBuiltin(Code* builtin, HowToCode how_to_code,
}
void CodeSerializer::SerializeCodeStub(Code* code, HowToCode how_to_code,
void CodeSerializer::SerializeCodeStub(Code* stub, HowToCode how_to_code,
WhereToPoint where_to_point, int skip) {
DCHECK((how_to_code == kPlain && where_to_point == kStartOfObject) ||
(how_to_code == kPlain && where_to_point == kInnerPointer) ||
(how_to_code == kFromCode && where_to_point == kInnerPointer));
uint32_t stub_key = code->stub_key();
if (stub_key == CodeStub::NoCacheKey()) {
if (FLAG_trace_code_serializer) {
PrintF("Encoding uncacheable code stub as heap object\n");
}
SerializeHeapObject(code, how_to_code, where_to_point, skip);
return;
}
uint32_t stub_key = stub->stub_key();
DCHECK(CodeStub::MajorKeyFromKey(stub_key) != CodeStub::NoCache);
if (skip != 0) {
sink_->Put(kSkip, "SkipFromSerializeCodeStub");
......
......@@ -607,7 +607,7 @@ class CodeSerializer : public Serializer {
private:
void SerializeBuiltin(Code* builtin, HowToCode how_to_code,
WhereToPoint where_to_point, int skip);
void SerializeCodeStub(Code* code, HowToCode how_to_code,
void SerializeCodeStub(Code* stub, HowToCode how_to_code,
WhereToPoint where_to_point, int skip);
void SerializeSourceObject(HowToCode how_to_code, WhereToPoint where_to_point,
int skip);
......
// Copyright 2014 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.
// Flags: --cache=code --serialize-toplevel
var foo = [];
foo[0] = "bar";
assertEquals(["bar"], foo);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment