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

Unified Diff: src/hydrogen.cc

Issue 9117034: New class for Date objects: caches individual date components. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 11 months 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 side-by-side diff with in-line comments
Download patch
Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index 862afe5d3a644bdccc9f918236653baa31e5b03b..5300253fba0a61f1ce9181b66f5224ce83cae5e9 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -6564,6 +6564,18 @@ void HGraphBuilder::GenerateValueOf(CallRuntime* call) {
}
+void HGraphBuilder::GenerateDateField(CallRuntime* call) {
+ ASSERT(call->arguments()->length() == 2);
+ ASSERT_NE(NULL, call->arguments()->at(1)->AsLiteral());
+ int index =
+ Smi::cast(*(call->arguments()->at(1)->AsLiteral()->handle()))->value();
+ CHECK_ALIVE(VisitForValue(call->arguments()->at(0)));
+ HValue* value = Pop();
+ HDateField* result = new(zone()) HDateField(value, index);
+ return ast_context()->ReturnInstruction(result, call->id());
+}
+
+
void HGraphBuilder::GenerateSetValueOf(CallRuntime* call) {
ASSERT(call->arguments()->length() == 2);
CHECK_ALIVE(VisitForValue(call->arguments()->at(0)));
@@ -6606,6 +6618,52 @@ void HGraphBuilder::GenerateSetValueOf(CallRuntime* call) {
}
+void HGraphBuilder::GenerateSetDateField(CallRuntime* call) {
+ ASSERT(call->arguments()->length() == 3);
+ ASSERT_NE(NULL, call->arguments()->at(1)->AsLiteral());
+ int index =
+ Smi::cast(*(call->arguments()->at(1)->AsLiteral()->handle()))->value();
+ CHECK_ALIVE(VisitForValue(call->arguments()->at(0)));
+ CHECK_ALIVE(VisitForValue(call->arguments()->at(2)));
+ HValue* value = Pop();
+ HValue* object = Pop();
+ // Check if object is a not a smi.
+ HIsSmiAndBranch* smicheck = new(zone()) HIsSmiAndBranch(object);
+ HBasicBlock* if_smi = graph()->CreateBasicBlock();
+ HBasicBlock* if_heap_object = graph()->CreateBasicBlock();
+ HBasicBlock* join = graph()->CreateBasicBlock();
+ smicheck->SetSuccessorAt(0, if_smi);
+ smicheck->SetSuccessorAt(1, if_heap_object);
+ current_block()->Finish(smicheck);
+ if_smi->Goto(join);
+
+ // Check if object is a JSDate.
+ set_current_block(if_heap_object);
+ HHasInstanceTypeAndBranch* typecheck =
+ new(zone()) HHasInstanceTypeAndBranch(object, JS_DATE_TYPE);
+ HBasicBlock* if_js_date = graph()->CreateBasicBlock();
+ HBasicBlock* not_js_date = graph()->CreateBasicBlock();
+ typecheck->SetSuccessorAt(0, if_js_date);
+ typecheck->SetSuccessorAt(1, not_js_date);
+ current_block()->Finish(typecheck);
+ not_js_date->Goto(join);
+
+ // Create in-object property store to right offset.
+ set_current_block(if_js_date);
+ Handle<String> name = isolate()->factory()->undefined_symbol();
+ AddInstruction(
+ new HStoreNamedField(object,
+ name,
+ value,
+ true, // in-object store.
+ JSDate::kYearOffset + kPointerSize * index));
+ if_js_date->Goto(join);
+ join->SetJoinId(call->id());
+ set_current_block(join);
+ return ast_context()->ReturnValue(value);
+}
+
+
// Fast support for charCodeAt(n).
void HGraphBuilder::GenerateStringCharCodeAt(CallRuntime* call) {
ASSERT(call->arguments()->length() == 2);
« no previous file with comments | « src/date.js ('k') | src/hydrogen-instructions.h » ('j') | src/hydrogen-instructions.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698