OLD | NEW |
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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 stream->Add("%s", MajorName(MajorKey(), false)); | 197 stream->Add("%s", MajorName(MajorKey(), false)); |
198 } | 198 } |
199 | 199 |
200 | 200 |
201 void CodeStub::PrintName(StringStream* stream) { | 201 void CodeStub::PrintName(StringStream* stream) { |
202 PrintBaseName(stream); | 202 PrintBaseName(stream); |
203 PrintState(stream); | 203 PrintState(stream); |
204 } | 204 } |
205 | 205 |
206 | 206 |
| 207 Builtins::JavaScript UnaryOpStub::ToJSBuiltin() { |
| 208 switch (operation_) { |
| 209 default: |
| 210 UNREACHABLE(); |
| 211 case Token::SUB: |
| 212 return Builtins::UNARY_MINUS; |
| 213 case Token::BIT_NOT: |
| 214 return Builtins::BIT_NOT; |
| 215 } |
| 216 } |
| 217 |
| 218 |
| 219 Handle<JSFunction> UnaryOpStub::ToJSFunction(Isolate* isolate) { |
| 220 Handle<JSBuiltinsObject> builtins(isolate->js_builtins_object()); |
| 221 Object* builtin = builtins->javascript_builtin(ToJSBuiltin()); |
| 222 return Handle<JSFunction>(JSFunction::cast(builtin), isolate); |
| 223 } |
| 224 |
| 225 |
| 226 MaybeObject* UnaryOpStub::Result(Handle<Object> object, Isolate* isolate) { |
| 227 Handle<JSFunction> builtin_function = ToJSFunction(isolate); |
| 228 bool caught_exception; |
| 229 Handle<Object> result = Execution::Call(builtin_function, object, |
| 230 0, NULL, &caught_exception); |
| 231 if (caught_exception) { |
| 232 return Failure::Exception(); |
| 233 } |
| 234 return *result; |
| 235 } |
| 236 |
| 237 |
| 238 void UnaryOpStub::UpdateStatus(Handle<Object> object) { |
| 239 State old_state(state_); |
| 240 if (object->IsSmi()) { |
| 241 state_.Add(SMI); |
| 242 if (operation_ == Token::SUB && *object == 0) { |
| 243 // The result (-0) has to be represented as double. |
| 244 state_.Add(HEAP_NUMBER); |
| 245 } |
| 246 } else if (object->IsHeapNumber()) { |
| 247 state_.Add(HEAP_NUMBER); |
| 248 } else { |
| 249 state_.Add(GENERIC); |
| 250 } |
| 251 TraceTransition(old_state, state_); |
| 252 } |
| 253 |
| 254 |
| 255 Handle<Type> UnaryOpStub::GetType(Isolate* isolate) { |
| 256 if (state_.Contains(GENERIC)) { |
| 257 return handle(Type::Any(), isolate); |
| 258 } |
| 259 Handle<Type> type = handle(Type::None(), isolate); |
| 260 if (state_.Contains(SMI)) { |
| 261 type = handle( |
| 262 Type::Union(type, handle(Type::Smi(), isolate)), isolate); |
| 263 } |
| 264 if (state_.Contains(HEAP_NUMBER)) { |
| 265 type = handle( |
| 266 Type::Union(type, handle(Type::Double(), isolate)), isolate); |
| 267 } |
| 268 return type; |
| 269 } |
| 270 |
| 271 |
207 void BinaryOpStub::Generate(MacroAssembler* masm) { | 272 void BinaryOpStub::Generate(MacroAssembler* masm) { |
208 // Explicitly allow generation of nested stubs. It is safe here because | 273 // Explicitly allow generation of nested stubs. It is safe here because |
209 // generation code does not use any raw pointers. | 274 // generation code does not use any raw pointers. |
210 AllowStubCallsScope allow_stub_calls(masm, true); | 275 AllowStubCallsScope allow_stub_calls(masm, true); |
211 | 276 |
212 BinaryOpIC::TypeInfo operands_type = Max(left_type_, right_type_); | 277 BinaryOpIC::TypeInfo operands_type = Max(left_type_, right_type_); |
213 if (left_type_ == BinaryOpIC::ODDBALL && right_type_ == BinaryOpIC::ODDBALL) { | 278 if (left_type_ == BinaryOpIC::ODDBALL && right_type_ == BinaryOpIC::ODDBALL) { |
214 // The OddballStub handles a number and an oddball, not two oddballs. | 279 // The OddballStub handles a number and an oddball, not two oddballs. |
215 operands_type = BinaryOpIC::GENERIC; | 280 operands_type = BinaryOpIC::GENERIC; |
216 } | 281 } |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 break; | 347 break; |
283 default: | 348 default: |
284 UNREACHABLE(); | 349 UNREACHABLE(); |
285 } | 350 } |
286 } | 351 } |
287 | 352 |
288 | 353 |
289 #undef __ | 354 #undef __ |
290 | 355 |
291 | 356 |
| 357 void UnaryOpStub::PrintBaseName(StringStream* stream) { |
| 358 CodeStub::PrintBaseName(stream); |
| 359 if (operation_ == Token::SUB) stream->Add("Minus"); |
| 360 if (operation_ == Token::BIT_NOT) stream->Add("Not"); |
| 361 } |
| 362 |
| 363 |
| 364 void UnaryOpStub::PrintState(StringStream* stream) { |
| 365 state_.Print(stream); |
| 366 } |
| 367 |
| 368 |
| 369 void UnaryOpStub::State::Print(StringStream* stream) const { |
| 370 stream->Add("("); |
| 371 SimpleListPrinter printer(stream); |
| 372 if (IsEmpty()) printer.Add("None"); |
| 373 if (Contains(GENERIC)) printer.Add("Generic"); |
| 374 if (Contains(HEAP_NUMBER)) printer.Add("HeapNumber"); |
| 375 if (Contains(SMI)) printer.Add("Smi"); |
| 376 stream->Add(")"); |
| 377 } |
| 378 |
| 379 |
292 void BinaryOpStub::PrintName(StringStream* stream) { | 380 void BinaryOpStub::PrintName(StringStream* stream) { |
293 const char* op_name = Token::Name(op_); | 381 const char* op_name = Token::Name(op_); |
294 const char* overwrite_name; | 382 const char* overwrite_name; |
295 switch (mode_) { | 383 switch (mode_) { |
296 case NO_OVERWRITE: overwrite_name = "Alloc"; break; | 384 case NO_OVERWRITE: overwrite_name = "Alloc"; break; |
297 case OVERWRITE_RIGHT: overwrite_name = "OverwriteRight"; break; | 385 case OVERWRITE_RIGHT: overwrite_name = "OverwriteRight"; break; |
298 case OVERWRITE_LEFT: overwrite_name = "OverwriteLeft"; break; | 386 case OVERWRITE_LEFT: overwrite_name = "OverwriteLeft"; break; |
299 default: overwrite_name = "UnknownOverwrite"; break; | 387 default: overwrite_name = "UnknownOverwrite"; break; |
300 } | 388 } |
301 stream->Add("BinaryOpStub_%s_%s_%s+%s", | 389 stream->Add("BinaryOpStub_%s_%s_%s+%s", |
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
796 InstallDescriptor(isolate, &stub3); | 884 InstallDescriptor(isolate, &stub3); |
797 } | 885 } |
798 | 886 |
799 InternalArrayConstructorStub::InternalArrayConstructorStub( | 887 InternalArrayConstructorStub::InternalArrayConstructorStub( |
800 Isolate* isolate) { | 888 Isolate* isolate) { |
801 InternalArrayConstructorStubBase::GenerateStubsAheadOfTime(isolate); | 889 InternalArrayConstructorStubBase::GenerateStubsAheadOfTime(isolate); |
802 } | 890 } |
803 | 891 |
804 | 892 |
805 } } // namespace v8::internal | 893 } } // namespace v8::internal |
OLD | NEW |