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

Side by Side Diff: src/ia32/full-codegen-ia32.cc

Issue 10915062: Add checks to runtime functions. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/date.js ('k') | src/ia32/lithium-codegen-ia32.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 3050 matching lines...) Expand 10 before | Expand all | Expand 10 after
3061 3061
3062 3062
3063 void FullCodeGenerator::EmitDateField(CallRuntime* expr) { 3063 void FullCodeGenerator::EmitDateField(CallRuntime* expr) {
3064 ZoneList<Expression*>* args = expr->arguments(); 3064 ZoneList<Expression*>* args = expr->arguments();
3065 ASSERT(args->length() == 2); 3065 ASSERT(args->length() == 2);
3066 ASSERT_NE(NULL, args->at(1)->AsLiteral()); 3066 ASSERT_NE(NULL, args->at(1)->AsLiteral());
3067 Smi* index = Smi::cast(*(args->at(1)->AsLiteral()->handle())); 3067 Smi* index = Smi::cast(*(args->at(1)->AsLiteral()->handle()));
3068 3068
3069 VisitForAccumulatorValue(args->at(0)); // Load the object. 3069 VisitForAccumulatorValue(args->at(0)); // Load the object.
3070 3070
3071 Label runtime, done; 3071 Label runtime, done, not_date_object;
3072 Register object = eax; 3072 Register object = eax;
3073 Register result = eax; 3073 Register result = eax;
3074 Register scratch = ecx; 3074 Register scratch = ecx;
3075 3075
3076 #ifdef DEBUG 3076 __ JumpIfSmi(object, &not_date_object);
3077 __ AbortIfSmi(object);
3078 __ CmpObjectType(object, JS_DATE_TYPE, scratch); 3077 __ CmpObjectType(object, JS_DATE_TYPE, scratch);
3079 __ Assert(equal, "Trying to get date field from non-date."); 3078 __ j(not_equal, &not_date_object);
3080 #endif
3081 3079
3082 if (index->value() == 0) { 3080 if (index->value() == 0) {
3083 __ mov(result, FieldOperand(object, JSDate::kValueOffset)); 3081 __ mov(result, FieldOperand(object, JSDate::kValueOffset));
3082 __ jmp(&done);
3084 } else { 3083 } else {
3085 if (index->value() < JSDate::kFirstUncachedField) { 3084 if (index->value() < JSDate::kFirstUncachedField) {
3086 ExternalReference stamp = ExternalReference::date_cache_stamp(isolate()); 3085 ExternalReference stamp = ExternalReference::date_cache_stamp(isolate());
3087 __ mov(scratch, Operand::StaticVariable(stamp)); 3086 __ mov(scratch, Operand::StaticVariable(stamp));
3088 __ cmp(scratch, FieldOperand(object, JSDate::kCacheStampOffset)); 3087 __ cmp(scratch, FieldOperand(object, JSDate::kCacheStampOffset));
3089 __ j(not_equal, &runtime, Label::kNear); 3088 __ j(not_equal, &runtime, Label::kNear);
3090 __ mov(result, FieldOperand(object, JSDate::kValueOffset + 3089 __ mov(result, FieldOperand(object, JSDate::kValueOffset +
3091 kPointerSize * index->value())); 3090 kPointerSize * index->value()));
3092 __ jmp(&done); 3091 __ jmp(&done);
3093 } 3092 }
3094 __ bind(&runtime); 3093 __ bind(&runtime);
3095 __ PrepareCallCFunction(2, scratch); 3094 __ PrepareCallCFunction(2, scratch);
3096 __ mov(Operand(esp, 0), object); 3095 __ mov(Operand(esp, 0), object);
3097 __ mov(Operand(esp, 1 * kPointerSize), Immediate(index)); 3096 __ mov(Operand(esp, 1 * kPointerSize), Immediate(index));
3098 __ CallCFunction(ExternalReference::get_date_field_function(isolate()), 2); 3097 __ CallCFunction(ExternalReference::get_date_field_function(isolate()), 2);
3099 __ bind(&done); 3098 __ jmp(&done);
3100 } 3099 }
3100
3101 __ bind(&not_date_object);
3102 __ CallRuntime(Runtime::kThrowNotDateError, 0);
3103 __ bind(&done);
3101 context()->Plug(result); 3104 context()->Plug(result);
3102 } 3105 }
3103 3106
3104 3107
3105 void FullCodeGenerator::EmitMathPow(CallRuntime* expr) { 3108 void FullCodeGenerator::EmitMathPow(CallRuntime* expr) {
3106 // Load the arguments on the stack and call the runtime function. 3109 // Load the arguments on the stack and call the runtime function.
3107 ZoneList<Expression*>* args = expr->arguments(); 3110 ZoneList<Expression*>* args = expr->arguments();
3108 ASSERT(args->length() == 2); 3111 ASSERT(args->length() == 2);
3109 VisitForStackValue(args->at(0)); 3112 VisitForStackValue(args->at(0));
3110 VisitForStackValue(args->at(1)); 3113 VisitForStackValue(args->at(1));
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
3515 3518
3516 context()->Plug(if_true, if_false); 3519 context()->Plug(if_true, if_false);
3517 } 3520 }
3518 3521
3519 3522
3520 void FullCodeGenerator::EmitGetCachedArrayIndex(CallRuntime* expr) { 3523 void FullCodeGenerator::EmitGetCachedArrayIndex(CallRuntime* expr) {
3521 ZoneList<Expression*>* args = expr->arguments(); 3524 ZoneList<Expression*>* args = expr->arguments();
3522 ASSERT(args->length() == 1); 3525 ASSERT(args->length() == 1);
3523 VisitForAccumulatorValue(args->at(0)); 3526 VisitForAccumulatorValue(args->at(0));
3524 3527
3525 if (generate_debug_code_) { 3528 __ AbortIfNotString(eax);
3526 __ AbortIfNotString(eax);
3527 }
3528 3529
3529 __ mov(eax, FieldOperand(eax, String::kHashFieldOffset)); 3530 __ mov(eax, FieldOperand(eax, String::kHashFieldOffset));
3530 __ IndexFromHash(eax, eax); 3531 __ IndexFromHash(eax, eax);
3531 3532
3532 context()->Plug(eax); 3533 context()->Plug(eax);
3533 } 3534 }
3534 3535
3535 3536
3536 void FullCodeGenerator::EmitFastAsciiArrayJoin(CallRuntime* expr) { 3537 void FullCodeGenerator::EmitFastAsciiArrayJoin(CallRuntime* expr) {
3537 Label bailout, done, one_char_separator, long_separator, 3538 Label bailout, done, one_char_separator, long_separator,
(...skipping 1016 matching lines...) Expand 10 before | Expand all | Expand 10 after
4554 *stack_depth = 0; 4555 *stack_depth = 0;
4555 *context_length = 0; 4556 *context_length = 0;
4556 return previous_; 4557 return previous_;
4557 } 4558 }
4558 4559
4559 #undef __ 4560 #undef __
4560 4561
4561 } } // namespace v8::internal 4562 } } // namespace v8::internal
4562 4563
4563 #endif // V8_TARGET_ARCH_IA32 4564 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/date.js ('k') | src/ia32/lithium-codegen-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698