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